{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9876","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9876/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9876/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9876/events","html_url":"https://github.com/Microsoft/TypeScript/issues/9876","id":166910751,"number":9876,"title":"Configuration Inheritance","user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/In%20Discussion","name":"In Discussion","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-21T20:31:10Z","updated_at":"2016-07-21T21:44:53Z","closed_at":null,"body":"Our friends from @angular asked for this feature while they were visiting last week, since they use a lot of configuration files internally.\r\n\r\nProposal\r\n======\r\n\r\nAdd a new top-level (alongside compilerOptions, files, includes, and excludes) `tsconfig` parameter - `extends` (to steal the term from [`eslint`](http://eslint.org/docs/developer-guide/shareable-configs)).\r\n\r\n- Its value is a string or an array of strings which are interpreted as rooted or relative paths (so starting with either a drive root or `.` 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. \r\n- If we add recommended or built-in configs to inherit from in the future, those will look like a module identifier, rather than a path (ie, `\"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.\r\n- All configs your config inherits from are first parsed and resolved (thereby filling in anything they inherit), and then merged. Configs later in the list override the configuration provided by those earlier in the list. Configuration in the active config can override those provided by an inheriting config. If a circularity is encountered, we report an error.\r\n- If any inherited configs we load have errors, we will report them.\r\n- Top-level members other than `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).\r\n- Paths other than those found in the `extends` key (ie, `excludes`, `includes`, `files`, and even `compilerOptions.paths` and `compilerOptions.typeRoots`) will __not__ be resolved from the location of the configuration. They will be copied __verbatim__ into the config that extends from them. There are pros and cons to this, but the biggest reason for not resolving them is that keeping track of all of the compiler options that are paths and need recalculation when extended from is a lot of effort (especially if future extensions take paths in their options).\r\n\r\nExamples\r\n======\r\n\r\n`configs/base.json`:\r\n```ts\r\n{\r\n  \"compilerOptions\": {\r\n    \"allowJs\": true,\r\n    \"noImplicitAny\": true,\r\n    \"strictNullChecks\": true\r\n  }\r\n}\r\n```\r\n\r\n`configs/tests.json`:\r\n```ts\r\n{\r\n  \"compilerOptions\": {\r\n    \"preserveConstEnums\": true,\r\n    \"stripComments\": false,\r\n    \"sourceMaps\": true\r\n  },\r\n  \"excludes\": [\r\n    \"tests/baselines\",\r\n    \"tests/scenarios\"\r\n  ],\r\n  \"includes\": [\r\n    \"tests/**/*.ts\"\r\n  ]\r\n}\r\n```\r\n\r\n`tsconfig.json`:\r\n```ts\r\n{\r\n  \"extends\": \"./configs/base\",\r\n  \"files\": [\r\n    \"main.ts\",\r\n    \"supplemental.ts\"\r\n  ]\r\n}\r\n```\r\n\r\n`tsconfig.nostrictnull.json`:\r\n```ts\r\n{\r\n  \"extends\": \"./tsconfig\"\r\n  \"compilerOptions\": {\r\n    \"strictNullChecks\": false\r\n  }\r\n}\r\n```\r\n\r\n`tsconfig.tests.json`:\r\n```ts\r\n  \"extends\": [\"./configs/tests\", \"./tsconfig\"],\r\n  \"compilerOptions\": {\r\n    \"module\": \"commonjs\"\r\n  }\r\n```\r\n\r\n`tsconfig.tests.browser.json`:\r\n```ts\r\n  \"extends\": [\"./configs/tests\", \"./tsconfig\"],\r\n  \"compilerOptions\": {\r\n    \"module\": \"amd\"\r\n  }\r\n```\r\n\r\n@alexeagle @DanielRosenwasser Does this cover your usecases?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/234393723","html_url":"https://github.com/Microsoft/TypeScript/issues/9876#issuecomment-234393723","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/9876","id":234393723,"user":{"login":"weswigham","id":2932786,"avatar_url":"https://avatars.githubusercontent.com/u/2932786?v=3","gravatar_id":"","url":"https://api.github.com/users/weswigham","html_url":"https://github.com/weswigham","followers_url":"https://api.github.com/users/weswigham/followers","following_url":"https://api.github.com/users/weswigham/following{/other_user}","gists_url":"https://api.github.com/users/weswigham/gists{/gist_id}","starred_url":"https://api.github.com/users/weswigham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weswigham/subscriptions","organizations_url":"https://api.github.com/users/weswigham/orgs","repos_url":"https://api.github.com/users/weswigham/repos","events_url":"https://api.github.com/users/weswigham/events{/privacy}","received_events_url":"https://api.github.com/users/weswigham/received_events","type":"User","site_admin":false},"created_at":"2016-07-21T21:44:53Z","updated_at":"2016-07-21T21:44:53Z","body":"@alexeagle Correct. Though, you could still have useful things such as\n`\"excludes\": [\"node_modules\"]`, which is probably still what you wanted\nregardless of where its resolved from. My general recommendation would be\nto avoid using paths in inheritable configurations unless you're really\nsure you want it. Generally, the config extends member will behave _mostly_\nas `Object.assign({}, ...extendedConfigs)`.  Or at least that's the intent.\nRewriting all the paths complicates that a lot... And requires knowledge of\nwhat is a path and what isn't.\n\nOn Thu, Jul 21, 2016, 1:54 PM Alex Eagle <notifications@github.com> wrote:\n\n> SGTM cc @igorminar <https://github.com/igorminar>\n>\n> I understand about file references being rooted relative to the file\n> requested by -p option, though that is clearly the thorny issue here, as\n> knowledge of resolution is non-local in the tsconfig containing the\n> reference. If tsconfig.json extends ./a.json and subdir/tsconfig.json\n> extends ../a.json there are no correct options for relative paths in\n> a.json?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/Microsoft/TypeScript/issues/9876#issuecomment-234381003>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ACzAMhFgri-59Jyl8Z3eMlQlAGGcJXu7ks5qX9yYgaJpZM4JSL8V>\n> .\n>\n"}}
{"actor":{"display_login":"weswigham"}}