microsoft / microsoft/TypeScript

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

Offen
#60,199 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Domain: Something Else Possible Improvement
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

🔎 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?)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in src/compiler/commandLineParser.ts bei matchesSpecs und convertToTSConfig, wo das Issue eine unterschiedliche Behandlung absoluter und relativer Include-Pfade meldet. Reproduziere die drei tsconfig-Fälle mit tsc --showConfig, bestimme dann die erwartete Dateiausgabe und überprüfe, dass sie mit den von --listFiles und dem Build ausgewählten Dateien übereinstimmt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
cli, compilers
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.