microsoft / microsoft/TypeScript

TS 5.6 `files` missing from `--showConfig` (with absolute / ``${configDir}`` `include` paths)

オープン
#60,199 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

Domain: Something Else Possible Improvement
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

🔎 Search Terms

"--showConfig", "include", "configDir", "files", "extends", "absolute"

🕗 Version & Regression Information
  • Tested versions:
    • 3.2.1 (--showConfig was introduced here)
    • 3.2.4
    • 5.5.2 (${configDir} was introduced here)
    • latest => 5.6.3
    • next =>5.7.0-dev.20241011
  • This is the behaviour in every version I tried, and I reviewed the FAQ for entries about "configDir", "showConfig", "absolute".
  • I was unable to test this on prior versions because --showConfig cli flag was introduced in TS 3.2 and configDir template variable was introduced in TS 5.5.
⏯ Playground Link

No response

💻 Code
// tsconfig-rel.json
{
    //...
    "include": ["src/**/*"]
}
// tsconfig-abs.json
{
    //...
    "include": ["/path/to/src/**/*"]
}
// tsconfig-cnf.json
{
    //...
    "include": ["${configDir}/src/**/*"]
}
// src/index.ts
console.log("dummy");
🙁 Actual behavior

Printing config yields different results.

npx tsc --project tsconfig-rel.json --showConfig
npx tsc --project tsconfig-abs.json --showConfig
npx tsc --project tsconfig-cnf.json --showConfig
  • For absolute include paths the files property is missing.
  • ${configDir} is resolved to and behaves / fails the same as absolute paths.
  {
      "compilerOptions": {...},
-     "files": [
-         "./src/index.ts"
-     ],
      "include": [
-         "src/**/*"
+         "/path/to/src/**/*"
      ],
      "exclude": [...]
  }

Listing files yields the same output.

npx tsc --project tsconfig-rel.json --listFiles --noEmit
npx tsc --project tsconfig-abs.json --listFiles --noEmit
npx tsc --project tsconfig-cnf.json --listFiles --noEmit

List of files printed to stdout, containing

  • /path/to/src/index.ts
  • /path/to/node_modules/**/*.d.ts entries from npm dependency type declarations.
  • /path/to/node_modules/typescript/lib/lib.decorators.d.ts (only in TS 5 of course)
  • /path/to/node_modules/typescript/lib/lib.decorators.legacy.d.ts (only in TS 5 of course)

Building yields the same index.js file content for all configs.

npx tsc --project tsconfig-rel.json
npx tsc --project tsconfig-abs.json
npx tsc --project tsconfig-cnf.json
🙂 Expected behavior

--showConfig should show the same files for configs that build the same files and show the same listing for --listFiles.

Additional information about the issue

includeRe in matchesSpecs seems to be calculated differently for absolute / relative paths, resulting in all files being filtered out in convertToTSConfig.

I can't tell though which behaviour is actually expected. (keep files or filter files out?)

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

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

はじめの一歩

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

調査の方向性

src/compiler/commandLineParser.ts の matchesSpecs と convertToTSConfig から始めます。ここでは、issue が絶対パスと相対パスの include パスで処理が異なることを報告しています。3 つの tsconfig ケースを tsc --showConfig で再現し、次に期待されるファイル出力を特定して、それが --listFiles とビルドによって選択されたファイルと一致することを確認します。

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

評価

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

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

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