TypeScript - tsconfig Deep Dive
Strictness
strict: Enables all strict options.
noImplicitAny, strictNullChecks, exactOptionalPropertyTypes, noUncheckedIndexedAccess
Module & Target
target: JS language level to emit (e.g., ES2020).
module: ESM/CJS/ESNext; bundlers often prefer ESNext.
moduleResolution: bundler, node, or nodenext.
JSX
jsx: react-jsx, react-jsxdev, or preserve.
Emit & Declarations
declaration, declarationMap, sourceMap
outDir, rootDir, removeComments
Project Layout
baseUrl & paths for import aliases
composite & references for multi-project builds
incremental & tsBuildInfoFile for faster rebuilds
Example tsconfig
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
"baseUrl": ".",
"paths": { "@/*": ["src/*"] }
},
"include": ["src"],
"exclude": ["dist", "node_modules"]
}