Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท tsconfig: Projects, Files and Watch Options

TypeScript compilerOptions field

Reference for the compilerOptions field in tsconfig.json: what it holds, how its groups are organized, comments in JSON, and how flags override it.

compilerOptions is the object inside tsconfig.json that holds almost all of the compiler's settings: strictness flags, the language level, module handling, emit choices and more. The other top-level fields (files, include, exclude, extends, references) decide which files are involved and how projects connect; compilerOptions decides how those files are checked and emitted.

Every option is optional. Anything you leave out takes its default, and several defaults depend on other options: strict turns on a family of flags, module influences moduleResolution, and target sets the default lib.

JSON
{
  "compilerOptions": {
    "strict": true,
    "target": "es2024",
    "module": "nodenext",
    "outDir": "dist"
  }
}

Try it

A tsconfig is JSON with comments and trailing commas allowed, but the options inside are plain data. This example reads a config string and reports which options are set.

TypeScript Reading a tsconfig-like object

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.

TypeScript Implied defaults

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

JSON
{
  "compilerOptions": {
    // JSON with comments is allowed in tsconfig.json
    "target": "es2024",
    "lib": ["es2024"],
    "types": ["node"],
  }
}
Name Description
compilerOptions An object of option names to values: booleans, strings, numbers, arrays of strings, or objects (like paths).

The options fall into groups, each covered by its own pages:

Group Examples
Type checking strict, noImplicitAny, noUnusedLocals
Language and environment target, lib, jsx
Modules module, moduleResolution, paths
Emit outDir, declaration, sourceMap, noEmit
Projects composite, incremental

Usage notes

  • Option names and enum-like string values are case-insensitive ("ES2024" equals "es2024"), but keeping them lowercase is the convention.
  • Unknown option names are reported as errors (TS5023); a typo is never silently ignored.
  • Command-line flags beat the file: tsc --strict false wins over "strict": true.
  • Paths in options (outDir, baseUrl, rootDir) are relative to the tsconfig that contains them.
  • Use tsc --init for a starter file, tsc --showConfig to see the final result, and tsc --help --all for every option.
  • When extends is used, compilerOptions merge key by key.