-
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
Configuration Inheritance #9876
Comments
Not to take anything away from the @angular team 😄, but other projects would benefit from this too. Currently @dojo is managing this via the tooling tasks which overwrite configuration "magically" when doing different targets, but it would be great to just provide this as a |
@kitsonk We actually started doing the same thing with our debug/release build duality inside the compiler, if you look at our gulpfile. 😆 |
SGTM cc @IgorMinar I understand about file references being rooted relative to the file requested by |
@alexeagle Correct. Though, you could still have useful things such as |
You could still do this if you say you are merging the "resolved" version of the config files. so you first look at the config file, and make all the file path properties absolute using the containing file location, something we already do today, then merge the result. |
+1 for resolving the config before merging. Tools will also have an On Thu, Jul 21, 2016 at 3:53 PM Mohamed Hegazy notifications@github.com
|
@mhegazy We could do that for the top-level options easily, but for things within the |
it is very hard to reason about relative paths when consumed in the context of a different file. we already mark some compiler options as |
@mhegazy But we don't currently mark members of object compiler options as paths (like the |
"paths" is not. it is always relative to |
for the extensions, this is a hard one. no idea what we can do there. these are opaque objects and we have no visibility in them. |
@mhegazy since Or maybe I should just not think about extensions, solve this for this, then rebuild the extensions argument structure on top of it? That sounds better, I think. In any case, I'll update the OP to reflect that we will resolve paths in all path-based options. |
This is certainly more versatile than my suggestion (##9835), yet, perhaps you would like to check with the angular team if the environment based solution (which avoids the relative paths issue) is good enough. I know they source multiple packages from one repo that each have their own I'm trying to follow the Angular 2 pattern my repo and figured I was doomed to copy settings everywhere. Multiplackage development it's so common that there is a popular NodeJS tool to support it: https://lernajs.io/ |
@alexeagle is the Angular team member interfacing with the TypeScript team... 😉 |
IMO the biggest problem to overcome in this change is for editors to catch up. We try to keep all the editors working which means we can't update to a new tsconfig.json feature for a long time after it's been added. |
I think this would be helpful for generating |
How would you use this to generate On Sat, Jul 23, 2016 at 7:54 PM Aluan Haddad notifications@github.com
|
Yes exactly. For example, it might run as a post install hook. |
Just curious why u need this, is this for jspm modules? |
@mhegazy Thank you for asking. Yes this is exactly what I am trying to do. I am working on some tools that parses jspm.config.js files to automatically install correctly versioned declaration files and map them to the package scoped import names via tsconfig.json. The plan is to use the information to determine the The only way I can think to do this, is to automatically generate paths. Are there are any plans for TypeScript to support jspm in the near future? I saw that the #2233 was recently closed. |
The correct fix here is for TS to add module resolution support for jspm modules. The concerns we had were the relative instability of the framework, the lack of documentation and the runtime configuration structure that is not friendly to static analyzers. I think w need to reasses this for TS2.1; but do not think the approach of auto generating path mapping is sustainable. |
I've opened #9941 with an implementation of the proposal thus far - it didn't seem like there was any contention over anything other than path handling. That question was resolved, so it seemed as though consensus had been reached, at least for now. |
@mhegazy I'm glad to know this is still under consideration and I really hope it gets implemented. Thank you for your feedback regarding the sustainability of auto generating path mapping. |
Why not support "tsconfig.js" in standard node format? |
This should be available in the nightly builds starting 9/14/2016 |
Shall this work with @next? Running In my {
"extends": "../tsconfig",
"module": "commonjs"
} Yet, when I compile my project I still have es6 modules everywhere :/ |
It isn't going to magically know what files are included and excluded, just based on its location and you would need to invoke the compiler twice. So in |
Hmm, I'm not sure if I follow correctly. These are my two typings.jsons /tsconfig.json {
"compileOnSave": true,
"compilerOptions": {
"target": "es6",
"module": "es6",
},
"include": [
"./server/**/*.ts",
"./client/**/*.ts",
"./client/**/*.tsx",
"./typings/**/*.ts",
"./shared/**/*.ts"
],
"exclude": [
"node_modules",
"./server/**/*.ts"
]
} and the /server/tsconfig.json {
"extends": "../tsconfig.json",
"module": "commonjs",
"include": ["./**/*.ts"]
} Now the server files are not emitted at all. |
Where did your extends go in |
Hi, I updated the above example. I simply executed tsc twice in the same destination. |
The file that extends a configuration should be a valid configuration file itself, i.e.: {
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs"
}
} |
@Aleksey-Bykov Alright. Done; but I don't think closed issues are normally considered a canonical source of documentation. 😛 |
@mhegazy Sorry for resurrecting this thread. In spite of your advice, which I still think is correct advice, I heedlessly went ahead with an experiment. I found that analyzing the |
In the original proposal it was suggested to allow using arrays as Here's our use case where it's needed to have multiple base config (array in Given an app written in TS. I have several dependencies installed via bower into vendor_components folder. The app have its own
The config "./vendor_components/ourFramework/tsconfig" is major, it describes all compilerOptions. But ourModule's config is also needed as it contains
So it's ok if a lib/fw in vendor_components contains its own tsconfig. If the app want include that lib/fw sources it should use that tsconfig as well. But currently it can use only one. Other's config have to replicated in app's tsconfig. |
Our friends from @angular asked for this feature while they were visiting last week, since they use a lot of configuration files internally.
Proposal
Add a new top-level (alongside compilerOptions, files, includes, and excludes)
tsconfig
parameter -extends
(to steal the term fromeslint
)..
or..
) from the current tsconfig to other tsconfigs to inherit from - with or without a.json
extension, if no extension is provided, we first look for an extensionless file by the name, and failing that, add a .json extension and look for that."typescript/strict"
). For now, non-relative, non-rooted paths will be an error. At present, built-in or shareable configs are not part of this proposal.compilerOptions
are completely overridden by following definitions.compilerOptions
at the top level is merged (though its individual keys will still be overridden as though they were top-level keys).Examples
configs/base.json
:configs/tests.json
:tsconfig.json
:tsconfig.nostrictnull.json
:tsconfig.tests.json
:tsconfig.tests.browser.json
:@alexeagle @DanielRosenwasser Does this cover your usecases?
The text was updated successfully, but these errors were encountered: