Skip to content
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

Support tsconfig inheritance #21

Open
danielmoore opened this issue Jan 11, 2017 · 10 comments
Open

Support tsconfig inheritance #21

danielmoore opened this issue Jan 11, 2017 · 10 comments

Comments

@danielmoore
Copy link

danielmoore commented Jan 11, 2017

As of TS 2.1, there is now an extends field that allows configs to inherit configuration from other files. It'd be great if this library emulated that behavior (though perhaps it should be configurable)

@blakeembrey
Copy link
Member

You're welcome to submit a PR, but I'm not sure I'll be implementing it myself here. If you need this, it's probably best to parse the tsconfig.json file using TypeScript to avoid additional changes in the future.

@nycdotnet
Copy link

If anyone's interested, I implemented support for extends in the grunt-ts tsconfig feature. The code to do so was fairly minimal, though I do have a dependency on underscore.

TypeStrong/grunt-ts#398

@Zerogiven
Copy link

I've made a PR #27 which handles "extends" (multiple too).

@blakeembrey at the moment i "just" wrote a little merge function for this behavior cause if we use the typescript api we could rewrite a bit more than i did.

@rifler
Copy link

rifler commented Apr 27, 2018

it's probably best to parse the tsconfig.json file using TypeScript to avoid additional changes in the future

I would be grateful to you if you can provide some docs, because I can't find it and ts codebase is too huge and difficult to search into.

And one more question

it's probably best ... using TypeScript to avoid additional changes in the future

So what is this library for? (no irony or gibe). In my opinion any manipulations with tsconfig.json should be done using TS to avoid additional changes in the future

@blakeembrey
Copy link
Member

@rifler Legacy. It used to be required because TypeScript didn't expose the features needed. It could still be used by people that want to load tsconfig.json files but don't want to include the entire TypeScript compiler. You can reference https://github.com/TypeStrong/ts-node if you'd like, it parses the file (there's a few different methods for slightly varying things, I had to read through the TypeScript codebase myself).

@rifler
Copy link

rifler commented May 7, 2018

Awesome, thank you so much, you save me a lot of time.

@ntucker
Copy link

ntucker commented Dec 1, 2019

@blakeembrey so how does one use the typescript package to load the config in a way that supports inheritance?

@blakeembrey
Copy link
Member

@ntucker You're best diving into the TypeScript package and taking a look. I left a link above to a package I maintain that can help you figure it out (it's not the best way due to legacy APIs in TypeScript).

@blakeembrey
Copy link
Member

blakeembrey commented Dec 1, 2019

@ntucker Try something like https://github.com/TypeStrong/ts-node/blob/4dbc15dc20da90c0496d117481a7467b6d637cb8/src/index.ts#L631 (not 100% sure from memory if that one method support inheritance, you might need to combine with parseJsonConfigFileContent). I believe there's a short-hand you can use exported by TypeScript that does both in a single function.

@ntucker
Copy link

ntucker commented Dec 1, 2019

https://stackoverflow.com/a/53898219/1046439 had the solution. Thanks for pointing me in the right direction @blakeembrey !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants