TypeScript Configuration
TypeScript Configuration: Core tsconfig.json Options
A tsconfig.json file sits at the root of your project and tells tsc which files to type-check, which JavaScript version to output, and how strict the type checker should be. Generating one with npx tsc --init gives you dozens of commented flags, though most projects need only 10–12 core settings.
Getting module, moduleResolution, and strict right upfront prevents cryptic import errors later.
Production-Ready tsconfig.json Baseline
For modern backend or bundler apps, enable "strict": true alongside "noUncheckedIndexedAccess": true and "isolatedModules": true.
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"noUncheckedIndexedAccess": true,
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
Key Options Explained
target: Controls which JavaScript syntaxtscemits (for example,ES2022keeps nativeasync/awaitand classes intact).strict: Turns onstrictNullChecks,noImplicitAny,strictFunctionTypes, andstrictBindCallApplytogether.skipLibCheck: Skips re-checking third-party.d.tsfiles insidenode_modules, cutting build times sharply.paths: Maps clean aliases like@/utils/*to./src/utils/*.
Common Mistakes to Avoid
- Enabling
pathswithout configuring your bundler or test runner:tsconly checkspathsaliases; Vite, Vitest, or Node loaders also need matching alias resolution. - Disabling
strictNullChecksto rush a prototype: Turning it off hides missing-property bugs until production. - Forgetting
"noEmit": truein Next.js or Vite projects: When your bundler emits JavaScript, set"noEmit": truesotscdoes not litter.jsfiles next to.tsfiles.
Frequently Asked Questions
What does "isolatedModules": true enforce?
It warns you whenever code uses TypeScript features (like const enum or re-exporting a type without export type) that single-file transpilers like Babel, esbuild, or SWC cannot compile safely.
Should I inherit from a shared preset?
Yes. Install @tsconfig/node22 or @tsconfig/next and write "extends": "@tsconfig/node22/tsconfig.json" instead of guessing flags manually.
How does include interact with exclude?
tsc starts from include patterns and removes matches from exclude. Even if node_modules is excluded, files imported directly from src/ are still resolved.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.