The `compilerOptions.outDir` config is incorrectly resolved when in a shareable config
See original GitHub issueTypeScript Version: 3.3.0-dev.20181222
Search Terms: outDir
, output directory
, outDir extends
Expected behavior:
TypeScript 3.2 got support for configuration inheritance via node_modules packages. I have created a package with a shareable config. In this shareable config, I have defined the outDir
option: https://github.com/sindresorhus/tsconfig/blob/50b0ba611480ed45b97a59b910f5bb5e8cbc25ef/tsconfig.json#L2-L3 as I always use the same outDir
and don’t want to have to specify it in each project.
I expected the outDir
path to be resolved against the project root, even when it’s defined in an extended config.
Actual behavior:
It turns out the outDir
relative path is actually resolved against the shareable config path instead of the project’s root (tsconfig.json
) path. So when I have a project foo
, and compile TypeScript, the output ends up in foo/@sindresorhus/tsconfig/dist
instead of foo/dist
.
You can reproduce it by cloning https://github.com/sindresorhus/ow/tree/8ae048c4931dfd51b496cefb40b24c78d3722be6, then removing this line https://github.com/sindresorhus/ow/blob/8ae048c4931dfd51b496cefb40b24c78d3722be6/tsconfig.json#L4 (which is a workaround to the problem), and then run $ npm test
. The compiled TS code will end up in node_modules/@sindresorhus/tsconfig/dist
instead of dist
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:66
- Comments:22 (3 by maintainers)
Top GitHub Comments
Rather than a breaking fix, couldn’t one just handle placeholder variables, such as $PROJECT_DIR or $ROOT_DIR? So the
outDir
in my common config file could be"$PROJECT_DIR/lib"
?Path-based compiler options (
outDir
,outFile
,rootDir
,include
,files
) are resolved from the config file they’re found in - we thought this’d be more consistent when combining config files, especially when you have multiple configs within the same project, as paths always get resolved relative to the file they were written in (so you can safely write references to any path you want in a config file without worrying about if that config getsextend
’d later on - its paths will continue to work).It would be horribly breaking to change this behavior now~