Was this page helpful?

What is a tsconfig.json

Overview

The presence of atsconfig.json file in a directory indicates that the directory is the root of a TypeScript project.Thetsconfig.json file specifies the root files and the compiler options required to compile the project.

JavaScript projects can use ajsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.

A project is compiled in one of the following ways:

Usingtsconfig.json orjsconfig.json

  • By invoking tsc with no input files, in which case the compiler searches for thetsconfig.json file starting in the current directory and continuing up the parent directory chain.
  • By invoking tsc with no input files and a--project (or just-p) command line option that specifies the path of a directory containing atsconfig.json file, or a path to a valid.json file containing the configurations.

When input files are specified on the command line,tsconfig.json files are ignored.

Examples

Exampletsconfig.json files:

TSConfig Bases

Depending on the JavaScript runtime environment which you intend to run your code in, there may be a base configuration which you can use atgithub.com/tsconfig/bases.These aretsconfig.json files which your project extends from which simplifies yourtsconfig.json by handling the runtime support.

For example, if you were writing a project which uses Node.js version 12 and above, then you could use the npm module@tsconfig/node12:

{
"":"@tsconfig/node12/tsconfig.json",
},
"": ["src/**/*"],
"": ["**/*.spec.ts"]
}

This lets yourtsconfig.json focus on the unique choices for your project, and not all of the runtime mechanics. There are a few tsconfig bases already, and we’re hoping the community can add more for different environments.

Details

The"compilerOptions" property can be omitted, in which case the compiler’s defaults are used. See our full list of supportedCompiler Options.

TSConfig Reference

To learn more about the hundreds of configuration options in theTSConfig Reference.

Schema

Thetsconfig.json Schema can be found atthe JSON Schema Store.

The TypeScript docs are an open source project. Help us improve these pagesby sending a Pull Request

Contributors to this page:
OTOrta Therox  (19)
LGLucas Garron  (1)
JBJake Bailey  (1)
L☺Loren ☺️  (1)
AGAnton Gilgur  (1)
4+

Last updated: Feb 18, 2026