microsoft / microsoft/TypeScript

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

Abierto
#60,199 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Domain: Something Else Possible Improvement
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en src/compiler/commandLineParser.ts, en matchesSpecs y convertToTSConfig, donde el issue informa de un tratamiento diferente de las rutas de inclusión absolutas y relativas. Reproduce los tres casos de tsconfig con tsc --showConfig, determina después la salida de archivos esperada y verifica que coincida con los archivos seleccionados por --listFiles y la compilación.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
cli, compilers
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.