microsoft / microsoft/TypeScript
`--showConfig` doesn't resolve `paths`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
"showConfig", "paths", "extends", "relative"
🕗 Version & Regression Information
v5.2.2 (no regression AFAIK)
⏯ Playground Link
https://stackblitz.com/edit/stackblitz-starters-gst2kr?file=tsconfig.json
Commands:
-
npm run config->tsc --showConfig -
npm run trace->tsc --noEmit --traceResolution
Use this to confirm thatfoodoes resolve to./this-path-should-be-in-config/bar.ts
💻 Code
No response
🙁 Actual behavior
Given a tsconfig that extends another config:
./tsconfig.json
{
"extends": "./this-path-should-be-in-config/tsconfig.json"
}
./this-path-should-be-in-config/tsconfig.json
{
"compilerOptions": {
"paths": {
"foo": ["./bar"]
}
}
}
The resolved tsconfig (via tsc --showConfig) doesn't reflect that ./bar is actually resolved relative to ./this-path-should-be-in-config/tsconfig.json:
{
"compilerOptions": {
"paths": {
"foo": [
"./bar"
]
}
},
"files": [
"./file.ts"
]
}
🙂 Expected behavior
For the config to include the relevant information (e.g. the relative path):
{
"compilerOptions": {
"paths": {
"foo": [
"./this-path-should-be-in-config/bar"
]
}
},
"files": [
"./file.ts"
]
}
Currently, it seems to indicate that paths is resolved relative to the CWD. When it's in fact relative to this-path-should-be-in-config.
It's also impossible for a custom TypeScript paths resolver (e.g. https://github.com/privatenumber/get-tsconfig) to correctly resolve the paths aliases based on this output.
Additional information about the issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction and run npm run config (tsc --showConfig) and npm run trace (tsc --noEmit --traceResolution). Compare the inherited paths values in the two tsconfig.json files with the resolved module path shown by tracing. Done means --showConfig reports the path relative to the extended configuration file, while preserving the demonstrated alias resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100