Skip to content

tsconfig Options Explained

The tsconfig options that matter, grouped by job: tighten type-checking, set the language target and modules, control what gets emitted, map import paths, structure multi-project builds, and tune the remaining checks.

A tsconfig tells the compiler which files to include and how strict to be. Two options do most of the work: target sets the JavaScript generation level, and strict turns on the safety checks as a bundle. The options below are the ones that change behavior; default-on flags are noted. Derive your config from a base, then override only what differs.

Reference table · 55 entries
55 of 55 rows
Strictness
Master switch: enables strictNullChecks, noImplicitAny, and several others at once.
Error on parameters and variables whose type cannot be inferred (would otherwise be any).
null and undefined are no longer assignable to every type; you opt in explicitly.
Check function parameters contravariantly; catches unsound callback parameter types.
Type-check bind, call, and apply against the function's declared parameters.
Error when a class property has no initial value and is not assigned in the constructor.
An optional property { p?: T } no longer accepts an explicit undefined assignment.
Require the override keyword on members that shadow a base-class member.
Error on declared local variables that are never read.
Error on declared function parameters that are never read.
Error on expression statements that have no effect.
Dot access is disallowed for index-signature keys; use brackets (obj["key"]).
Error when a code path returns a value but another does not.
Error when a switch case falls through to the next without a break.
Language & modules
The JavaScript generation level (e.g. ES2022); newer targets emit less down-leveling.
The built-in APIs available (e.g. ES2022, DOM, DOM.Iterable).
The module system emitted (e.g. ESNext, CommonJS, NodeNext).
Use Node's real rules: each file picks CJS or ESM from the nearest package.json, and relative imports need file extensions.
How import paths are resolved (e.g. bundler, node, nodenext).
How a file counts as a module: auto (by import/export presence), legacy, or force (always).
Allow default-import style from CommonJS modules (default true with most setups).
Allow default imports from modules that only export named values (type-level only).
Imports are emitted exactly as written; type-only imports must use import type (TS 5).
Let imports load .json files as typed values.
Include .js files as input to compilation.
Type-check .js files too, reading their JSDoc comments; implies allowJs.
How .tsx is compiled: react-jsx (automatic runtime), react (React.createElement), or preserve.
Restrict auto-included @types packages to this list; an empty array includes none.
Folders scanned for @types packages instead of every node_modules/@types up the tree.
Ensure every file can be transpiled in isolation (required by bundlers and esbuild).
Emit
Where compiled JavaScript is written.
The root of the source files; keeps the output tree shape stable.
Emit .js.map files so debuggers map back to TypeScript.
Embed the source map as a comment inside the .js file instead of a .js.map file.
Emit .d.ts type declarations (needed for libraries).
Emit .d.ts.map files so editors jump from declarations back to TypeScript source.
Emit only .d.ts files; JavaScript is left to a bundler (requires declaration or composite).
Reuse helpers like __rest from tslib instead of emitting them into every file.
Correct for..of, spread, and destructuring over iterables when target predates ES2015.
Strip comments from the emitted JavaScript.
Type-check only; write no files (used when a bundler does the emit).
Paths
A base directory for non-relative module resolution.
Map import prefixes to locations, e.g. { "@/*": ["src/*"] }.
Treat several directories as one virtual root for resolution.
Project structure
Mark a project as buildable for project references (enables declaration, incremental).
Depend on other tsconfig projects for faster, isolated builds.
Save build info to skip re-checking unchanged files next run.
Other checks
Skip type-checking of .d.ts files for speed (default true).
Error on imports that disagree with the file's actual casing.
Array and index access returns T | undefined, not T.
Class fields are created with Object.defineProperty instead of plain assignment (default true for ES2022+ targets).
Enable the legacy decorator syntax used by older frameworks (pre-standard).
Report full type names in error messages instead of truncating long ones.
Error when a bare side-effect import (import "./x.css") resolves to nothing.
Allow import paths ending in .ts (requires noEmit or emitDeclarationOnly).