Lesson

TypeScript Configuration

10 min reading
Free Course

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 syntax tsc emits (for example, ES2022 keeps native async/await and classes intact).
  • strict: Turns on strictNullChecks, noImplicitAny, strictFunctionTypes, and strictBindCallApply together.
  • skipLibCheck: Skips re-checking third-party .d.ts files inside node_modules, cutting build times sharply.
  • paths: Maps clean aliases like @/utils/* to ./src/utils/*.

Common Mistakes to Avoid

  • Enabling paths without configuring your bundler or test runner: tsc only checks paths aliases; Vite, Vitest, or Node loaders also need matching alias resolution.
  • Disabling strictNullChecks to rush a prototype: Turning it off hides missing-property bugs until production.
  • Forgetting "noEmit": true in Next.js or Vite projects: When your bundler emits JavaScript, set "noEmit": true so tsc does not litter .js files next to .ts files.

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.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
TypeScript Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum