TypeScript Reference ยท tsconfig: Projects, Files and Watch Options
TypeScript tsconfig extends option
Reference for the tsconfig extends field: inherit from another config file or a package, how compilerOptions merge, arrays and paths, and multiple bases.
extends lets one tsconfig start from another. The child file inherits every setting of the base and then adds or overrides its own. That avoids copying the same twenty options into each package of a monorepo, and lets you publish shared presets such as @tsconfig/node24.
The value is a path to a JSON file (relative paths start with ./ or ../), or the name of an npm package whose tsconfig.json or exports entry is used. Since TypeScript 5.0 it can also be an array of bases, applied left to right so later ones win.
{ "extends": "./tsconfig.base.json", "compilerOptions": { "outDir": "dist" } }
Try it
The rules are simple: compilerOptions are merged key by key, and every other top-level field is replaced whole. This model runs the same logic.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
{ "extends": ["@tsconfig/strictest/tsconfig.json", "./tsconfig.base.json"], "compilerOptions": { "rootDir": "src", "outDir": "dist" }, "include": ["src"] }
| Name | Description |
|---|---|
extends |
A string, or an array of strings. Each is a relative file path or a package specifier. |
Usage notes
files,includeandexcludein the child overwrite the base's values; they are not merged.- Relative paths inside a base config (
outDir,rootDir,include) are resolved from the file where they are written, not from the child. A base saved in a parent folder therefore points to that folder'sdist. pathsreplaces the whole object instead of combining entries.referencesis never inherited.- Circular
extendschains are an error. - Command-line flags override everything from the config chain.
tsc --showConfigprints the final merged result, the best way to check inheritance.