...

/

Nested Configuration

Nested Configuration

Learn how to use nested configuration in TypeScript to override compiler options and compile specific source files.

Introduction to nested configuration

The TypeScript compiler is able to reuse a tsconfig.json file in another directory when compiling code in the current directory. This feature is handy if we would like to override a compiler option when running tsc within a specific directory. The tsconfig.json file uses the extends option for this purpose.

Example of nested configuration

As an example of nested configuration, consider the following source tree:

├── sub1
│ ├── SampleJsFile.js
│ └── tsconfig.json
├── SampleTsFile.ts
└── tsconfig.json

Here, we have a tsconfig.json file in the project root directory as well as a TypeScript file named SampleTsFile.ts. We also have a subdirectory named sub1 that contains a tsconfig.json file and a JavaScript file named SampleJsFile.js.

Root directory tsconfig.json

The tsconfig.json file in the project root directory is as follows:

Access this course and 1400+ top-rated courses and projects.