Skip to content

different results if --outDir using relative path is in parent or child tsconfig #24851

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

Closed
nolazybits opened this issue Jun 11, 2018 · 6 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@nolazybits
Copy link

nolazybits commented Jun 11, 2018

Hello,

I don't know if it's intentional or not but given this structure:

* base.tsconfig.json
* aFolder/
      * tsconfig.json (extends base.tsconfig.json)

Actual behavior:
Now running tsc in aFolder:

  • if I have an outDir option in the base.tsconfig.json defined as ./dist it will create the dist folder in the root folder
* base.tsconfig.json
* aFolder/
      * tsconfig.json (extends base.tsconfig.json)
* dist/
  • if I have an outDir option in the aFolder/tsconfig.json defined as ./dist it will create the dist folder under the aFolder
* base.tsconfig.json
* aFolder/
      * tsconfig.json (extends base.tsconfig.json)
      * dist/
  • if I don't specify any outDir files are output in the aFolder folder

Expected behavior:
I would expect the dist folder to be created relatively to the path of the main tsconfig used by typescript (here tsconfig.json) regardless if outDir has been specified in the parent or child tsconfig.json

@mhegazy
Copy link
Contributor

mhegazy commented Jun 11, 2018

File paths are relative to the containing tsconfig.jon file location.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jun 11, 2018
@nolazybits
Copy link
Author

@mhegazy thanks for the comment.

I understand, though using the extend keyword I would expect the relative path to be relative to the child tsconfig (as I am "extending" the parent, not "including" it).
The current way means that any configuration that requires relative path will need to be duplicated in all children tsconfig which seems counter intuitive.
Would you know a workaround maybe?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2018

That is a design choice that we made when the feature was first implemented. the rational is files do not really move around, so for path that were originally authored as relative paths, it is strange for these to move around just because the file was used as abase.
The conceptual model to use is that of a class extending a base class, you inherit all the props from the base and you can override them, rather that of a template.

@nolazybits
Copy link
Author

Thanks for your answers :)

@hrajchert
Copy link

I'm having a similar problem, it's there a way that we can use "${cwd}/dist", use an env variable or similar?

@dietergeerts
Copy link

This is really annoying. apart from other settings I already need to duplicate, I need to duplicate outDir too in all our packages. If only we could use a JavaScript file as config, so we can use cwd if we want to, and other dynamic configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants