microsoft / microsoft/TypeScript

Mechanism to specify input source location to find `package.json` instead of output source location when determining module format

オープン
#63,251 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs Proposal Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

🔎 Search Terms

nodenext, ts2351, construct

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "A default import of a commonjs module with a default in a esm file doesn't seem to be the default export of that module when module is node16 or nodenext".
⏯ Playground Link

N/A

💻 Code
git clone https://github.com/monsanto/typescript-nodenext-bug
cd typescript-nodenext-bug
npm install
npm run tsc
🙁 Actual behavior
foo/index.ts:6:5 - error TS2351: This expression is not constructable.
  Type 'typeof import("<dir>/typescript-nodenext-bug/.cache/foolib/class")' has no construct signatures.

6 new CBad();
      ~~~~


Found 1 error.
🙂 Expected behavior

It succeeds.

Additional information about the issue
  • This issue requires a composite project, NodeNext, a package boundary, a default export, and a parent directory with a file package.{json, json5, yaml} without type: module.
    • Please note that import default inside foo's package boundary works.
    • One can delete the provided package.json after installing and run node_modules/typescript/bin/tsc --build tsconfig-base.json to test without package.json present.
    • One can see other package extensions trigger the bug by mv package.json package.yaml and pnpm run tsc.
  • This is not a CommonJS project. It doesn't matter that there is a parent package.json without it. Node doesn't even read package.yaml.
    • This is from a real-world monorepo where there is a root pnpm package.json5 for cross-package scripts.

Cross-ref for #62200

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされている typescript-nodenext-bug の再現から始めます。npm install と npm run tsc を実行し、その後、tsconfig-base.json と、issue で説明されている package.json、package.json5、package.yaml の各バリエーションを調べます。親パッケージのメタデータが存在する場合と存在しない場合で NodeNext モジュール形式の結果を比較します。再現が TS2351 なしで成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, typescript
領域
build-system, compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。