8000 `tsconfig.extends` as array · Issue #29118 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
tsconfig.extends as array #29118
Closed
Closed
@mutech

Description

@mutech

Search Terms

tsconfig extends array

Suggestion

Support defining the "extends" option as array of filenames.

{ "extends": [ "a", "b", "c" ] }

would have the same result as extending c where c extends b and b extends a.

Use Cases

This would make it so much easier to compose modular configuration fragments, analogue to "presets" in babel.

Examples

Given a set of tsconfig files containing fragments:

  • tsconfig/check.json (strict: ...)
  • tsconfig/sourcemap.json (sourceMap: ...)
  • tsconfig/declarations.json (declarations: ...)
  • tsconfig/aliases.json (paths: common aliases)
  • tsconfig/aliases.react.json (extends: aliases, paths: for react)
  • tsconfig/aliases.preact.json (extends: aliases, paths: for preact)
  • tsconfig/webpack.json (settings supporting tree shaking)
  • tsconfig/babel.json (settings to let babel handle platform issues)
  • tsconfig/node.json (settings to target node)
  • tsconfig/browser.json (settings to target browsers)
  • tsconfig/base.json (general defaults)
  • ...

It would be possible to combine these fragments in a way that is much more expressive and easier to
understand than flat config files.

A/tsconfig.preact.json:

{
  "extends": ["base", "sourcemap", "declarations", "babel", "browser", "aliases.preact"],
  "compilerOptions": {
     "declarationDir": "build/A/typings",
     "outDir": "build/A-preact"
  },
  "files": [ "src/A/index.ts" ]
}

A/tsconfig.react.json:

{
  "extends": ["base", "sourcemap", "declarations", "babel", "browser", "aliases.react"],
  "compilerOptions": {
     "declarationDir": "build/A/typings",
     "outDir": "build/A-react"
  },
  "files": [ "src/A/index.ts" ]
}

tsconfig.webpack.json

{
  "extends": ["base", "webpack],
  "compilerOptions": {
  }
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

Labels

CommittedThe team has roadmapped this issueFix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0