Web & Standards

tsconfig.json JSON Example

A real-world example of a TypeScript tsconfig.json — compiler options, module resolution, and path aliases for a modern Next.js/React project. Copy-ready starting point.

{
  "compilerOptions": {
    "target": "ES2020",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "module": "esnext",
    "moduleResolution": "bundler",
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "baseUrl": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  },
  "include": [
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

Field Reference

compilerOptions.strictoptionalbooleanEnables all strict type-checking flags at once (noImplicitAny, strictNullChecks, etc.) — the recommended baseline for any new project
compilerOptions.moduleResolutionoptionalstring'bundler' matches how modern bundlers (Next.js, Vite) actually resolve imports; 'node' is the older CommonJS-style resolution
compilerOptions.pathsoptionalobjectImport alias map — e.g. '@/*' → './src/*' lets you write import x from '@/lib/x' instead of relative '../../../lib/x'
compilerOptions.noUncheckedIndexedAccessoptionalbooleanMakes arr[i] and obj[key] return T | undefined instead of T, catching a very common class of runtime 'undefined is not an object' bugs at compile time
include / excludeoptionalarrayGlob patterns controlling which files TypeScript type-checks — exclude node_modules is near-universal for performance

Variants

Node.js Backend (CommonJS)A leaner config for a plain Node.js service, not a bundled frontend app.
Node.js Backend (CommonJS)
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "commonjs",
    "moduleResolution": "node",
    "strict": true,
    "outDir": "./dist",
    "rootDir": "./src",
    "esModuleInterop": true
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

Common Use Cases

  • Bootstrapping compiler options for a new TypeScript project without starting from a blank file
  • Setting up '@/*' import aliases to avoid long relative import paths
  • Understanding what a specific compiler flag (found in someone else's repo) actually does
typescripttsconfigconfigcompilerbuild

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

It tells TypeScript to resolve imports the way modern bundlers do — allowing extensionless imports and package.json 'exports' field resolution — rather than emulating older Node.js CommonJS resolution rules. Use it whenever a bundler (Next.js, Vite, esbuild) is doing the actual bundling.

strict: true already enables noImplicitAny, strictNullChecks, strictFunctionTypes, and the rest of the strict-family flags — you only need to list an individual flag separately if you want to override it to false while keeping the others on.

TypeScript does skip node_modules by default when it isn't explicitly included, but adding it to exclude is cheap insurance against a broad include pattern (like '**/*.ts') accidentally sweeping it back in, and it makes the intent explicit for anyone reading the config.

Related JSON Examples