question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The `compilerOptions.outDir` config is incorrectly resolved when in a shareable config

See original GitHub issue

TypeScript 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:open
  • Created 5 years ago
  • Reactions:66
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

64reactions
MartinDoyleUKcommented, Apr 25, 2019

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"?

49reactions
weswighamcommented, Jan 2, 2019

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 gets extend’d later on - its paths will continue to work).

It would be horribly breaking to change this behavior now~

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
All relative paths found in the configuration file will be resolved relative to the configuration file they originated in. It's worth noting that...
Read more >
Setting up tsconfig with spec/test folder - Stack Overflow
I ended up defining multiple config files and use extends to simplify them. ... "compilerOptions": { // I set outDir to place all...
Read more >
تويتر \ Monica Dinculescu على تويتر: "@thetombell Ducky mini 2 ...
The `compilerOptions.outDir` config is incorrectly resolved when in a shareable config · Issue... TypeScript Version: 3.3.0-dev.20181222 Search Terms: ...
Read more >
Typescript does not resolve modules through tsconfig.json's ...
If there is a 'files' section in tsconfig.json, WebStorm applies config settings to a file only if it is included in this section...
Read more >
How to set up a TypeScript monorepo and make Go ... - Medium
omitting the compilerOptions.paths settings so that the ... outDir` config is incorrectly resolved when in a shareable config · Issue…
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found