TypeScript tsconfig Patterns Reference

Type: Software Reference Confidence: 0.94 Sources: 7 Verified: 2026-02-28 Freshness: 2026-02-28

TL;DR

Constraints

Quick Reference

OptionRecommendedPurpose
stricttrueAll strict type checks
target"es2022"Emit syntax level
module"esnext" / "nodenext"Module system
moduleResolution"bundler" / "nodenext"How TS finds modules
skipLibChecktrueSkip .d.ts checking
isolatedModulestrueRequired by esbuild/swc/Vite
verbatimModuleSyntaxtrueExplicit type-only imports
noUncheckedIndexedAccesstrueIndex returns T | undefined
resolveJsonModuletrueImport .json files
declarationtrue (libs)Generate .d.ts files
incrementaltrueFaster rebuilds
noEmittrue (bundler)Bundler handles emit

Decision Tree

START
├── Pure Node.js (no bundler)?
│   ├── YES → module: "nodenext", moduleResolution: "nodenext"
│   └── NO ↓
├── Using Vite, webpack, esbuild?
│   ├── YES → module: "esnext", moduleResolution: "bundler", noEmit: true
│   └── NO ↓
├── Building npm library?
│   ├── YES → declaration: true, declarationMap: true, outDir: "./dist"
│   └── NO ↓
├── React project?
│   ├── YES → jsx: "react-jsx"
│   └── NO ↓
├── Monorepo?
│   ├── YES → composite: true, references: [...]
│   └── NO ↓
└── DEFAULT → strict: true, target: "es2022", skipLibCheck: true

Step-by-Step Guide

1. Initialize tsconfig.json

Generate a starter config. [src5]

npx tsc --init

Verify: ls tsconfig.json → file exists

2. Set base options

Essential options for every project. [src2]

{
  "compilerOptions": {
    "strict": true,
    "target": "es2022",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "noUncheckedIndexedAccess": true,
    "resolveJsonModule": true,
    "forceConsistentCasingInFileNames": true,
    "moduleDetection": "force"
  }
}

3. Configure module resolution

Choose based on bundler vs Node.js. [src4]

// For bundlers (Vite, webpack):
{ "module": "esnext", "moduleResolution": "bundler", "noEmit": true }

// For pure Node.js:
{ "module": "nodenext", "moduleResolution": "nodenext", "outDir": "./dist" }

Code Examples

Vite + React + TypeScript

{
  "compilerOptions": {
    "strict": true, "target": "es2022",
    "lib": ["es2022", "dom", "dom.iterable"],
    "module": "esnext", "moduleResolution": "bundler",
    "isolatedModules": true, "noEmit": true,
    "jsx": "react-jsx",
    "skipLibCheck": true, "noUncheckedIndexedAccess": true,
    "verbatimModuleSyntax": true,
    "baseUrl": ".", "paths": { "@/*": ["./src/*"] }
  },
  "include": ["src", "vite-env.d.ts"]
}

Node.js + Express Backend

{
  "compilerOptions": {
    "strict": true, "target": "es2022", "lib": ["es2022"],
    "module": "nodenext", "moduleResolution": "nodenext",
    "outDir": "./dist", "rootDir": "./src",
    "sourceMap": true, "declaration": true, "incremental": true,
    "skipLibCheck": true, "noUncheckedIndexedAccess": true,
    "verbatimModuleSyntax": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

npm Library

{
  "compilerOptions": {
    "strict": true, "target": "es2022", "lib": ["es2022"],
    "module": "esnext", "moduleResolution": "bundler",
    "outDir": "./dist", "rootDir": "./src",
    "declaration": true, "declarationMap": true, "sourceMap": true,
    "skipLibCheck": true, "noUncheckedIndexedAccess": true,
    "isolatedModules": true, "verbatimModuleSyntax": true
  },
  "include": ["src/**/*"],
  "exclude": ["**/*.test.ts"]
}

Anti-Patterns

Wrong: Skipping strict mode

// ❌ BAD — silent any, null bugs everywhere
{ "compilerOptions": { "strict": false, "target": "es5" } }

Correct: Always enable strict

// ✅ GOOD — catches bugs at compile time
{ "compilerOptions": { "strict": true, "target": "es2022" } }

Wrong: Using "moduleResolution": "node" with a bundler

// ❌ BAD — "node" is legacy, misses package.json exports
{ "module": "esnext", "moduleResolution": "node" }

Correct: Use "bundler" with bundlers

// ✅ GOOD — supports exports, no extension requirement
{ "module": "esnext", "moduleResolution": "bundler" }

Common Pitfalls

Diagnostic Commands

# Show fully resolved tsconfig
npx tsc --showConfig

# Type-check without emitting
npx tsc --noEmit

# List files that would be compiled
npx tsc --listFiles

# Check TypeScript version
npx tsc --version

# Build with verbose diagnostics
npx tsc --extendedDiagnostics

Version History & Compatibility

VersionStatusKey AdditionsNotes
TS 5.7CurrentFully supports all listed options
TS 5.5StableisolatedDeclarations, extends arrays
TS 5.4StableverbatimModuleSyntax finalizedReplaces importsNotUsedAsValues
TS 5.0LTSmoduleResolution: "bundler"First with bundler resolution
TS 4.xEOLUpgrade to 5.x

When to Use / When Not to Use

Use WhenDon't Use WhenUse Instead
Any TypeScript projectUsing Denodeno.json compilerOptions
Need precise type checkingQuick prototypePlain JS
Building npm librariesUsing Bun exclusivelybunfig.toml

Important Caveats

Related Units