tsconfig.json Reference
Reference of the most useful tsconfig.json keys, grouped by purpose. Most projects need 10–15 of these — not all of them.
Top-level keys
| Key | What it does |
|---|---|
compilerOptions | All compiler flags. |
include | Glob list of source files. |
exclude | Globs to skip. |
files | Explicit file list (overrides include). |
extends | Inherit another config (file or @tsconfig/* preset). |
references | Project references for monorepos. |
ts-node | Options for the ts-node runner (when used). |
Output
| Option | Effect |
|---|---|
target | JS version to emit. "ES2022" is the modern default. |
module | Module system — NodeNext / ESNext / Bundler. |
moduleResolution | How imports are resolved. |
outDir | Where compiled files go. |
rootDir | Source root. |
declaration | Emit .d.ts. |
declarationMap | Emit .d.ts.map. |
sourceMap | Emit .js.map. |
noEmit | Type-check only. |
noEmitOnError | Skip output if any errors. |
Strictness
| Option | Effect |
|---|---|
strict | Turns on the family of strict checks. |
noImplicitAny | Reject implicit anys. |
strictNullChecks | null / undefined are distinct types. |
strictFunctionTypes | Correct variance on functions. |
strictPropertyInitialization | Class fields must be initialised. |
noUncheckedIndexedAccess | arr[i] is T | undefined. |
exactOptionalPropertyTypes | ?: doesn't allow explicit undefined. |
noImplicitReturns | Forbid partial-return paths. |
noFallthroughCasesInSwitch | switch without break must end branch. |
noImplicitOverride | Require override on subclass methods. |
useUnknownInCatchVariables | catch(e) — e is unknown. |
noUnusedLocals / noUnusedParameters | Dead code warnings. |
Modules & resolution
| Option | Effect |
|---|---|
esModuleInterop | Smoother default imports from CJS. |
resolveJsonModule | Import JSON files. |
allowSyntheticDefaultImports | For type-only purposes. |
verbatimModuleSyntax | Require import type for type-only. |
baseUrl + paths | Path aliases. |
types | Only include named global type packages. |
Performance
| Option | Effect |
|---|---|
skipLibCheck | Skip type-checking node_modules .d.ts. |
incremental | Cache for faster reruns. |
composite | Required for project references. |
tsBuildInfoFile | Cache file location. |
Tip: For "I just want sane defaults" use a published preset:
"extends": "@tsconfig/node20/tsconfig.json" (or react / vite / etc.) and override only what you need. Less to maintain.Example
Example
// Top-level keys in tsconfig.json:
// compilerOptions, include, exclude, files, references, extends
//
// Useful inheritance:
// {
// "extends": "@tsconfig/node20/tsconfig.json",
// "compilerOptions": { "outDir": "dist" }
// }
console.log('The @tsconfig/* packages share sane presets');
Try it Yourself »
Exercise
Inherit another tsconfig with…
"
": "@tsconfig/node20/tsconfig.json"
Seven letters.
Discussion
Loading…