`index.d.cts` makes CommonJS TypeScript projects using `module: node16` fail with TS1479
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- firebase, react, typescript
調査の方向性
Start by reading the build:types-cjs script and comparing dist/index.d.ts with dist/index.d.cts; the issue says the latter is copied from the former. Reproduce the TS1479 errors with module and moduleResolution set to node16 and skipLibCheck: false, then inspect the local declaration re-exports. Done means the CommonJS TypeScript project can type-check its reactfire import without those errors.
索引モデルが issue の本文から書いたものです。
説明
A CommonJS TypeScript project that uses module: node16 and skipLibCheck: false cannot type-check an import of reactfire. I found this while reviewing #838, and it is already true on main.
What happens
tscreports TS1479 on every line ofnode_modules/reactfire/dist/index.d.ctsthat imports or re-exports a local file: "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'."- I got 11 of these on
mainand 12 on #838's head, where the extra one is the new./utils.jsre-export. - With
skipLibCheck: truethe errors go away and the imported types still resolve correctly, so projects with that setting are not affected. - attw reports all four resolution modes green, so the CI "Verify package" job does not catch it.
Steps to reproduce
- Create a project with no
"type"field in itspackage.jsonand atsconfig.jsonwithmoduleandmoduleResolutionset tonode16,skipLibCheck: false. - Install
reactfire(I used a tarball packed frommainateb3376a),firebase13.1.0 and React 19. - Import
useUserfromreactfirein a.tsfile and runtsc.
Cause, as far as I can tell
- The
build:types-cjsscript copiesdist/index.d.tstodist/index.d.cts, so the two files are identical. - The
.d.ctsfile is treated as CommonJS, but it re-exports from./auth.jsand the other per-module declarations, which sit in a"type": "module"package and are therefore ESM.
I have not tried a fix. If emitting real CommonJS declarations is more than this is worth, documenting skipLibCheck: true for CommonJS projects may be enough.
- 主要言語
- TypeScript
- スター
- 3.6k
- フォーク
- 402
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FirebaseExtended/reactfire のほかの issue
-
enhancement
難易度 1/5 1〜3時間 初心者へのやさしさ 64/100
FirebaseExtended/reactfire#851 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
FirebaseExtended/reactfire#801 ·
メンテナーはふだん 2 日以内に返信
-
v5
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
FirebaseExtended/reactfire#793 ·
メンテナーはふだん 2 日以内に返信
-
v5
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
FirebaseExtended/reactfire#790 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
v5
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
FirebaseExtended/reactfire#789 ·
メンテナーはふだん 2 日以内に返信
FirebaseExtended/reactfire の issue をすべて見る
似ている issue
-
bug needs-triage potential-regression
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/aws-sdk-js-v3#8408 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
colinhacks/zod#6743 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Packing list: the weight field drops digits on a slow connection and saves the wrong weightオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
openai/openai-node#3124 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
anthropics/anthropic-sdk-typescript#1296 ·
メンテナーはふだん 8 日以内に返信