You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript: expand ${configDir} in inherited tsconfig paths #13
tsconfig.json allows the variable ${configDir} in path options such as outDir, rootDir, baseUrl and paths. It stands for the directory of the top-level config file, so a shared base config can point at the project that extends it. The TypeScript reader in #12 reads these options but does not expand the variable.
What happens
sindresorhus/ky at 0d59458a0a extends @sindresorhus/tsconfig, whose tsconfig.json has:
"outDir": "${configDir}/distribution"
With node_modules present, load_typescript_config returns out_dir as:
That directory does not exist, so the compiled-target mapping from outDir back to rootDir cannot fire.
Why it does not show today
ky's seven entry points are still found, because the fallback added in #12 (a distribution/ target maps to a unique source/ file) covers this case. So the facts are right for ky. A project whose source root is not src/ or source/, or whose base config sets paths with ${configDir}, would get a wrong or missing mapping with no line saying so.
Fix
In typescript_config.py, when reading a path option from any file in the extends chain, replace ${configDir} with the directory of the top-level tsconfig.json before resolving it. The TypeScript documentation for ${configDir} is the reference for the rule.
Acceptance
Written before the change:
On ky at the pinned commit with node_modules installed, out_dir resolves to <repo>/distribution.
A fixture whose base config sets "paths": { "@/*": ["${configDir}/src/*"] } resolves @/lib/util to the source module.
Activity
fix: expand ${configDir} in inherited tsconfig paths