A Strict tsconfig.json for Modern TypeScript Projects

A
Author
02 Jun, 2026 1 min read 1.29K views

tsconfig.json has over a hundred options. These are the ones that matter most for catching bugs in a modern project.

{
  "compilerOptions": {
    "target": "es2022",
    "module": "nodenext",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "noFallthroughCasesInSwitch": true,
    "exactOptionalPropertyTypes": true,
    "verbatimModuleSyntax": true,
    "isolatedModules": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "outDir": "dist",
    "sourceMap": true
  },
  "include": ["src"]
}

The important ones

strict turns on a family of checks, including strictNullChecks (no more "undefined is not a function") and noImplicitAny.

noUncheckedIndexedAccess makes array and record lookups possibly undefined, which matches reality:

const names = ['Asha'];
const second = names[1];  // string | undefined with this flag
second.toUpperCase();     // Error: 'second' is possibly 'undefined'

exactOptionalPropertyTypes distinguishes "property missing" from "property set to undefined", which matters for PATCH-style updates.

verbatimModuleSyntax and isolatedModules keep your code compatible with fast single-file transpilers such as esbuild, SWC and Node's type stripping.

Module settings

  • Node.js apps and libraries: "module": "nodenext".
  • Code bundled by Vite, Next.js or esbuild: "module": "esnext" with "moduleResolution": "bundler".

Adopting strictness in an existing codebase

  1. Turn on strict and count the errors.
  2. Fix one folder at a time, or use // @ts-expect-error with a TODO on the hardest cases.
  3. Add the extra flags one by one once strict is clean.
Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.