iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

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

KeyWhat it does
compilerOptionsAll compiler flags.
includeGlob list of source files.
excludeGlobs to skip.
filesExplicit file list (overrides include).
extendsInherit another config (file or @tsconfig/* preset).
referencesProject references for monorepos.
ts-nodeOptions for the ts-node runner (when used).

Output

OptionEffect
targetJS version to emit. "ES2022" is the modern default.
moduleModule system — NodeNext / ESNext / Bundler.
moduleResolutionHow imports are resolved.
outDirWhere compiled files go.
rootDirSource root.
declarationEmit .d.ts.
declarationMapEmit .d.ts.map.
sourceMapEmit .js.map.
noEmitType-check only.
noEmitOnErrorSkip output if any errors.

Strictness

OptionEffect
strictTurns on the family of strict checks.
noImplicitAnyReject implicit anys.
strictNullChecksnull / undefined are distinct types.
strictFunctionTypesCorrect variance on functions.
strictPropertyInitializationClass fields must be initialised.
noUncheckedIndexedAccessarr[i] is T | undefined.
exactOptionalPropertyTypes?: doesn't allow explicit undefined.
noImplicitReturnsForbid partial-return paths.
noFallthroughCasesInSwitchswitch without break must end branch.
noImplicitOverrideRequire override on subclass methods.
useUnknownInCatchVariablescatch(e) — e is unknown.
noUnusedLocals / noUnusedParametersDead code warnings.

Modules & resolution

OptionEffect
esModuleInteropSmoother default imports from CJS.
resolveJsonModuleImport JSON files.
allowSyntheticDefaultImportsFor type-only purposes.
verbatimModuleSyntaxRequire import type for type-only.
baseUrl + pathsPath aliases.
typesOnly include named global type packages.

Performance

OptionEffect
skipLibCheckSkip type-checking node_modules .d.ts.
incrementalCache for faster reruns.
compositeRequired for project references.
tsBuildInfoFileCache 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"

Test yourself

Q1. Project reference key is…
Q2. Inherit from another config with…
Q3. Strict checks go in…

Discussion

Loading…