BACK TO DIRECTORY
settingintermediate
TypeScript Strict Mode
The most comprehensive TypeScript configuration for maximum type safety. Enables all strict flags plus additional checks like noUncheckedIndexedAccess, exactOptionalPropertyTypes, and noPropertyAccessFromIndexSignature. Includes recommended ESLint rules for TypeScript and explains the rationale behind each setting. Ideal for new projects starting with strict typing from day one.
678 STARS
9.9k DOWNLOADS
claude-templates
typescriptstricttypesconfigsafety
CONFIGURATION
json
1{2 "compilerOptions": {3 // Strict type checking4 "strict": true,5 "noUncheckedIndexedAccess": true,6 "exactOptionalPropertyTypes": true,7 "noPropertyAccessFromIndexSignature": true,8 "noImplicitReturns": true,9 "noFallthroughCasesInSwitch": true,10 "noImplicitOverride": true,11 "forceConsistentCasingInFileNames": true,12 "verbatimModuleSyntax": true,1314 // Module resolution15 "target": "ES2022",16 "module": "ESNext",17 "moduleResolution": "bundler",18 "resolveJsonModule": true,19 "isolatedModules": true,20 "esModuleInterop": true,2122 // Output23 "noEmit": true,24 "declaration": true,25 "declarationMap": true,26 "sourceMap": true,2728 // Paths29 "baseUrl": ".",30 "paths": {31 "@/*": ["./src/*"]32 },3334 // Libraries35 "lib": ["DOM", "DOM.Iterable", "ES2022"],36 "jsx": "preserve",37 "incremental": true,3839 // Plugins40 "plugins": [{ "name": "next" }]41 },42 "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],43 "exclude": ["node_modules", "dist", ".next"]44}4546// What each strict flag does:47// strict: true -> Enables all strict mode flags48// noUncheckedIndexedAccess -> array[0] is T | undefined49// exactOptionalPropertyTypes -> { x?: string } is string | undefined, not string | undefined | missing50// noPropertyAccessFromIndexSignature -> forces obj["key"] over obj.key for index signatures51// noImplicitReturns -> every code path must return a value52// noFallthroughCasesInSwitch -> switch cases must break or return53// noImplicitOverride -> override keyword required for inherited methods54// verbatimModuleSyntax -> enforces type-only imports with "import type"