-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
tsconfig.json - extends property should handle more than one config paths #42386
Comments
Related / duplicate: #29118. Used search terms: |
Oh, you are right. Sorry for that. |
The issue that you provided was opened on Dec 21, 2018 and there is no response from contributors and finally it was closed on Aug 22, 2020. Is this feature possible? I don't think it is that hard to develop / little bit refactor. |
I would rather say that multiple inheritance is bad even in the context of tsconfigs. I personally tend to generate tsconfig files before performing typescript builds. This allows me to create quite sophisticated pipelines. IMO, tsconfigs' syntax should be as blunt and featureless as possible and any extension and re-usability should be achieved at a meta level. |
Hi! Thanks for your advice, I'll consider it in the future. |
I've reopened #29118 |
The same argument would hold for single inheritance. The proposition adds no features that you could not achieve with single inheritance, except for providing a better composability. I agree that the additional complexity always adds a risk. However, the complexity of build pipelines is already suffocating and adding to that complexity is no less risky or painful. The solution for most developers who are not working on an industrial scale is typically Copy & Paste, painful comparisons of different tsconfigs, painful research in the docs to remember conflicting settings or their precise semantics. To me, the current limitation looks like the complexity is already there, we just deny ourselves to benefit from its existence. |
I think it's more interesting to follow this issue, since there are conflicting opinions here. |
Oh I meant that your ticket is more interesting, if closing was a reaction on my comment ;-) |
Sorry, I have little problem with understanding english. Maybe two duplicated issues make contributors think about this after several years. |
I agree that I rarely need this feature, however when I use any of the 'tsconfig' packages, e.g. https://www.npmjs.com/package/@tsconfig/node12, I often want to use both that and some base config that has my common rules in. Currently, the only way to use tsconfig packages is to maintain parity -- which is, to some extent just fine. |
I would just like to post a concrete example I've come across where multiple inheritance could potentially be helpful. I've been setting up a Typescript monorepo structure that looks something like this. Of course, there are other workspaces besides just
Now, you may be wondering why there are two different versions of tsconfig, both at the root level and the workspace level. This is because I've been following the technique described in this article for allowing better integration with tooling such as VSCode. The technique relies on utilizing path aliases while in development, but excluding them when running the build. For example, this is my current root level
However, once you get to the workspace level and you setup the same For a
So, naively one might think that being able to do something like this is a great idea...
But then you have to decide which order the array items should be, to indicate which should take precedence in the event of a conflict, and there's not necessarily a correct answer there. It would also probably mean that the compiler would need a mechanism for resolving the diamond problem whenever it is encountered. My personal opinion is that it would be awesome to have this feature, and people can use at their own risk. Edit: Just realized that this flag already exists! |
This feature is mentioned in the 5.0 release blog post though it's still not mentioned in the tsconfig extends documentation |
So is this available in typescript 5 ? |
Yes. It seems to be working for me. |
This is implemented, but not yet documented here: https://www.typescriptlang.org/tsconfig/#extends |
Suggestion - tsconfig.json - extends more than one configs
🔍 Search Terms
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
A
tsconfig.json
havecompilerOptions
,include
,files
andextends
, I'll be describing theextends
feature suggestion.It only takes a
string
type which is a path to thetsconfig.json
, but it would be useful to take more paths.So
extends
property should be able to process one or more paths.📃 Motivating Example
Below I attached an example code image of what this can be helpful for. The image shown tree of 7 config parts in the left side and the code example on the right of
extends
them together.💻 Use Cases
What do you want to use this for?
It will give a lot of possibilities.
For example, you will be able to make one configs directory and mixing them via
extends
for best config and fast project configuration.What shortcomings exist with current approaches?
Inconvenience: you need to chain them one by one, which is of course not the best practice. If you will add another one and next ot it will be another 10 files then it takes some time to make it works again.
What workarounds are you using in the meantime?
Chaining them (b extends a, c extends b, etc.).
Or you can even make some script that generates certain config from other parts.
Or maybe some package that includes all files into one.
The text was updated successfully, but these errors were encountered: