Advanced Types and Real-World PatternsLesson 6.5
TypeScript project configuration strict mode and performance tips
strict mode flags breakdown, noUncheckedIndexedAccess, paths aliases, project references, skipLibCheck, incremental compilation
What strict mode enables
"strict": true enables several flags at once. The most impactful:
{
"compilerOptions": {
"strict": true,
// Included: strictNullChecks, noImplicitAny,
// strictFunctionTypes, strictPropertyInitialization,
// strictBindCallApply, noImplicitThis
}
}Additional recommended flags
{
"compilerOptions": {
"noUncheckedIndexedAccess": true, // arr[i] returns T | undefined
"exactOptionalPropertyTypes": true, // ? means absent, not undefined
"noImplicitReturns": true, // all paths must return
"noFallthroughCasesInSwitch": true
}
}Performance: large codebases
{
"compilerOptions": {
"incremental": true, // cache build info
"skipLibCheck": true, // skip .d.ts checking in node_modules
"isolatedModules": true // compatible with esbuild/swc
}
}Path aliases clean up deep imports:
{
"compilerOptions": {
"paths": { "@/*": ["./src/*"] }
}
}Enable noUncheckedIndexedAccess from project start โ retrofitting it later is painful but it catches real bugs on every array access.
