Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stabpd opened this issue Oct 11, 2024 · 3 comments
Labels
Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@stabpd
Copy link

stabpd commented Oct 11, 2024

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

@RyanCavanaugh RyanCavanaugh added the Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases label Oct 11, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Oct 11, 2024
@RyanCavanaugh
Copy link
Member

I don't know if anyone is really putting absolute paths in their config files; this seems like a nonstandard usage. showConfig is intended for human consumption so it's not really wrong for it to do different things given different inputs. Not sure what the "best" behavior is but if someone really needs to change it to some provably better outcome, they can.

@stabpd
Copy link
Author

stabpd commented Oct 14, 2024

I agree that this is not an urgent matter. Let me add a little clarification for future discussion though:

For me, it's not about manually configured absolute paths, but about ${configDir} which has the same issue, because the template variable gets substituted with absolute paths internally.

When switching from a monolithic config to a base tsconfig.json that I could extend, I wanted to verify changes via showConfig. Seeing no files there, no matter what I did, almost made me discard using that nice new ${configDir} feature.

I can live with the current behaviour, now that I know. But maybe this will confuse other users as well, leading them down the wrong path too.

@aztack
Copy link

aztack commented May 26, 2025

Will the absence of the files field have a substantial impact? Or is it still there, just not displayed whe tsc --showConfig is executed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy