Skip to main content

TypeScript tsconfig.json Cheatsheet — 55+ Compiler Options with Defaults and Examples

TypeScript tsconfig.json cheat sheet — 55+ options with defaults, examples, and gotchas.

  • Runs locally
  • Category Developer & DevOps
  • Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Category:
51 option(s)
Type Checking(15)
strictbooleanDefault: false

Umbrella flag that enables seven strict checks at once: noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, and useUnknownInCatchVariables. Start every new project with this. Migrate existing projects incrementally using `// @ts-nocheck` on noisy files.

"strict": true

⚠ Pitfall Enabling strict on a large existing codebase can produce thousands of errors at once. Use `// @ts-nocheck` at the top of noisy files while migrating, rather than suppressing every error individually.

noImplicitAnybooleanDefault: false (true with strict)

Raises an error when TypeScript would infer `any` due to missing type information. The most common trigger is an un-annotated function parameter — `function foo(x)` becomes an error, forcing you to write `function foo(x: string)`.

"noImplicitAny": true
strictNullChecksbooleanDefault: false (true with strict)

Makes `null` and `undefined` their own distinct types instead of being assignable to every type. Without this flag, forgetting to handle null is a silent bug. With it, you must explicitly narrow with checks, use the non-null assertion (`!`), or include `null` in a union type.

"strictNullChecks": true

⚠ Pitfall The most common migration error is forgetting to add `| null | undefined` to return types of functions that can return nothing.

strictFunctionTypesbooleanDefault: false (true with strict)

Enforces contravariance for function parameter types in callback positions. Catches bugs where you pass a function that accepts a narrower type than the callback expects. Note: method declarations (not arrow functions) remain bivariant for compatibility.

"strictFunctionTypes": true
strictBindCallApplybooleanDefault: false (true with strict)

Enables stricter checking of arguments passed to `bind`, `call`, and `apply`. Without this, these methods accept `any` arguments regardless of the function signature.

"strictBindCallApply": true
strictPropertyInitializationbooleanDefault: false (true with strict)

Raises an error for class properties that are declared but not initialized in the constructor. Requires `strictNullChecks`. Use the definite assignment assertion (`!`) only when you genuinely control initialization order outside the constructor (e.g. dependency injection).

"strictPropertyInitialization": true

⚠ Pitfall Don't prefix every property with `!` to silence the error — that defeats the purpose. Use it only for properties initialized in lifecycle hooks or injected by a framework.

noImplicitThisbooleanDefault: false (true with strict)

Raises an error when `this` has an implicit `any` type, which typically occurs in standalone functions and object literals where TypeScript can't determine the type of `this`. Fix by adding a `this: ClassName` parameter to the function signature.

"noImplicitThis": true
useUnknownInCatchVariablesbooleanDefault: false (true with strict)TS 4.0

Makes caught variables in `catch` clauses typed as `unknown` instead of `any`. Forces you to narrow the type before accessing it — safer because `throw` can throw any value, not just `Error` instances.

"useUnknownInCatchVariables": true

⚠ Pitfall Use `if (error instanceof Error)` or a type guard. Casting directly to `Error` without a check is unsafe — `throw "a string"` is valid JavaScript.

noUnusedLocalsbooleanDefault: false

Reports errors for local variables that are declared but never read. Prefix intentionally unused variables with `_` (e.g. `_index` in a callback) to suppress the error without removing them.

"noUnusedLocals": true
noUnusedParametersbooleanDefault: false

Reports errors for function parameters that are declared but never used. Like `noUnusedLocals`, prefix with `_` to mark intentionally unused parameters.

"noUnusedParameters": true
noImplicitReturnsbooleanDefault: false

Reports an error when not all code paths in a non-void function have a `return` statement. Prevents the classic "forgot a return in the else branch" bug in complex if/else chains.

"noImplicitReturns": true
noFallthroughCasesInSwitchbooleanDefault: false

Reports an error for any non-empty `case` in a switch statement that falls through to the next case without a `break`, `return`, or `throw`. Empty cases (a series of `case X: case Y:`) are still allowed.

"noFallthroughCasesInSwitch": true
exactOptionalPropertyTypesbooleanDefault: falseTS 4.4

Differentiates between "property is absent" and "property is set to undefined". An optional property `x?: string` allows `obj.x = "foo"` or omitting `x` entirely, but NOT `obj.x = undefined`. This is the most accurate model of optional properties.

"exactOptionalPropertyTypes": true

⚠ Pitfall Many codebases use `obj.x = undefined` to "unset" a property. With this flag you must use `delete obj.x` instead, or change the type to `x?: string | undefined`.

noUncheckedIndexedAccessbooleanDefault: falseTS 4.1

Adds `undefined` to array index access and index signature access return types. Since `arr[5]` may be out of bounds, TypeScript requires `arr[5] !== undefined` checks before use. Catches a very common class of runtime errors.

"noUncheckedIndexedAccess": true

⚠ Pitfall This flag is NOT enabled by `strict` — you opt in manually. It can be very noisy in array-heavy code. Where you are certain the index exists, use `arr[i]!` (non-null assertion).

noPropertyAccessFromIndexSignaturebooleanDefault: false

Requires bracket notation (`obj["key"]`) instead of dot notation (`obj.key`) when accessing a property defined via an index signature. Makes it visually clear which accesses are "safe" (declared) vs "dynamic" (index signature).

"noPropertyAccessFromIndexSignature": true
Modules(8)
modulestringDefault: "CommonJS" (for ES3/ES5 target)

Controls what module format TypeScript emits. `"CommonJS"` generates `require()`/`module.exports` (Node.js classic). `"ESNext"` generates `import`/`export` (for bundlers). `"NodeNext"` enables full Node.js ESM with `.js` extensions required in imports.

"module": "NodeNext"

⚠ Pitfall For Vite/webpack: use `"ESNext"` + `"moduleResolution": "bundler"`. For Node.js ESM: use `"NodeNext"` for both `module` and `moduleResolution`. Never mix `"ESNext"` module with `"node10"` resolution.

moduleResolutionstringDefault: "node10" for CommonJS moduleTS "bundler" added in 5.0

Determines how TypeScript locates module files. `"bundler"` (TS 5.0+) matches modern bundlers like Vite/esbuild — no file extensions required. `"NodeNext"` mirrors Node.js 12+ resolution, requiring `.js` extensions. `"node10"` is the legacy Node.js resolution strategy.

"moduleResolution": "bundler"
resolveJsonModulebooleanDefault: false

Allows importing `.json` files with automatic type inference based on the JSON structure. Very useful for importing config files, locale strings, or static data sets directly into TypeScript.

"resolveJsonModule": true

⚠ Pitfall Large JSON files are fully type-checked and bundled, which can slow compilation and increase bundle size. For very large data files, consider loading them at runtime.

allowImportingTsExtensionsbooleanDefault: falseTS 5.0

Allows imports of `.ts`, `.tsx`, and `.mts` files with their explicit extensions in `import` statements. Requires `noEmit` or `emitDeclarationOnly` to be enabled, since TypeScript cannot handle `.ts` extensions in emitted JavaScript.

"allowImportingTsExtensions": true
allowJsbooleanDefault: false

Lets TypeScript process `.js` and `.jsx` files alongside `.ts`. Useful when incrementally migrating a JavaScript project — you can convert one file at a time without renaming everything.

"allowJs": true
checkJsbooleanDefault: false

Enables type checking in `.js` files (requires `allowJs`). TypeScript uses type inference and JSDoc annotations to check JavaScript. A great starting point when adopting TypeScript in a JS codebase before adding explicit type annotations.

"checkJs": true
verbatimModuleSyntaxbooleanDefault: falseTS 5.0

Enforces `import type` for type-only imports and `export type` for type-only exports. Errors if you import a type without the `type` keyword. Ensures type imports are stripped at compile time without needing Babel or other tools. Replaces `importsNotUsedAsValues`.

"verbatimModuleSyntax": true

⚠ Pitfall You will need to add `type` to all existing type-only imports — `import { Foo }` becomes `import type { Foo }`. Most editors can auto-fix this with a quick action.

moduleDetection"auto" | "legacy" | "force"Default: "auto"TS 4.7

Controls how TypeScript determines whether a file is a module or a script. `"auto"`: a file is a module if it contains `import`/`export` or `import.meta`. `"force"`: every non-declaration file is treated as a module — useful to prevent accidental global declarations.

"moduleDetection": "force"
Emit(12)
targetstringDefault: "ES3"

Sets the JavaScript language version TypeScript emits. Modern projects should use `"ES2022"` or `"ESNext"`. Affects both syntax transforms (async/await, optional chaining) and which built-in types are available via `lib`. A mismatch between `target` and actual runtime can cause subtle failures.

"target": "ES2022"

⚠ Pitfall Setting `target` higher than your actual runtime supports causes runtime errors. For example, `"ES2022"` on Node 12 will fail for methods like `Array.at()` that were added later.

libstring[]Default: depends on target

Specifies built-in API type definitions to include. When omitted, TypeScript automatically includes a lib set based on `target`. Common additions: `"DOM"` for browser APIs, `"DOM.Iterable"` for iterable DOM collections. Omit `"DOM"` in Node.js projects to avoid browser-type bleed.

"lib": ["ES2022", "DOM", "DOM.Iterable"]
outDirstringDefault: (beside source files)

Specifies the output directory for compiled files. TypeScript mirrors the source directory structure inside `outDir`. Combine with `rootDir` for predictable output layout. Add `outDir` to `.gitignore`.

"outDir": "./dist"
rootDirstringDefault: (inferred from input files)

Specifies the root of your TypeScript source files. Used with `outDir` to compute output paths — the directory structure under `rootDir` is replicated under `outDir`. Set explicitly to `"./src"` if TypeScript infers it incorrectly.

"rootDir": "./src"
declarationbooleanDefault: false

Emits `.d.ts` declaration files alongside the compiled `.js`. Required when publishing a TypeScript library so consumers get type information. Combine with `emitDeclarationOnly` to generate types without JavaScript.

"declaration": true
declarationMapbooleanDefault: false

Emits `.d.ts.map` source map files alongside `.d.ts` files. Allows editors to "Go to Definition" in the original `.ts` source instead of the generated `.d.ts`. Greatly improves the developer experience for library consumers who have the source available.

"declarationMap": true
sourceMapbooleanDefault: false

Emits `.js.map` source map files that map compiled JavaScript back to the original TypeScript. Enables debuggers and error reporting tools (Sentry, etc.) to show TypeScript line numbers instead of compiled JavaScript. Essential for production debugging.

"sourceMap": true
noEmitbooleanDefault: false

Runs the type checker but does not write any output files to disk. Ideal when a bundler (Vite, esbuild, webpack) handles compilation — TypeScript is used only for type checking. Pair with `isolatedModules: true` for the fastest type-check pass.

"noEmit": true
emitDeclarationOnlybooleanDefault: false

Emits only `.d.ts` type declaration files, not `.js` files. The perfect setup when publishing a library: TypeScript generates types via `tsc`, the bundler generates JavaScript. Requires `declaration: true`.

"emitDeclarationOnly": true
removeCommentsbooleanDefault: false

Strips all comments from the emitted JavaScript. Does not affect `.d.ts` declaration files. Useful when your TypeScript source is heavily commented with JSDoc but you want a lean output bundle. Triple-slash reference directives (`/// <reference>`) are always preserved.

"removeComments": true
importHelpersbooleanDefault: false

Imports helpers (`__awaiter`, `__extends`, `__assign`, etc.) from `tslib` instead of inlining them in every compiled file. When many files use the same helpers, this reduces overall bundle size. Requires `tslib` as a dependency.

"importHelpers": true
downlevelIterationbooleanDefault: false

Enables correct iteration over iterables (for...of, spread, destructuring) when compiling to ES5 or ES3 targets. Without it, TypeScript uses a simpler but incorrect implementation. Use `importHelpers: true` with `tslib` to avoid inlining the iterator helper in every file.

"downlevelIteration": true
Interop(7)
esModuleInteropbooleanDefault: false

Enables interoperability between CommonJS and ES module `import` syntax. Without it, `import React from "react"` fails for modules that export only `module.exports` (no `.default` property). With it, TypeScript adds helper code so default imports work for CJS modules. Automatically enables `allowSyntheticDefaultImports`.

"esModuleInterop": true

⚠ Pitfall This adds runtime helper functions (`__importDefault`, `__importStar`). Use `importHelpers: true` with `tslib` to import them once rather than duplicating them in each file.

allowSyntheticDefaultImportsbooleanDefault: true when esModuleInterop is enabled

Allows `import Foo from 'module'` when the module doesn't explicitly export a default. This is type-checking only — it emits no runtime code. When `esModuleInterop` is on, this is set automatically. If you also need runtime behavior, use `esModuleInterop`.

"allowSyntheticDefaultImports": true
isolatedModulesbooleanDefault: false

Ensures each file can be safely transpiled in isolation without type information from other files. Required when using Babel, esbuild, or SWC to compile TypeScript. Raises errors for things that only work with full type info: `const enum`, non-type re-exports, and ambient module declarations.

"isolatedModules": true

⚠ Pitfall `const enum` is completely disallowed — switch to regular `enum` or a const object. Use `import type` for all type-only imports to ensure correct stripping.

forceConsistentCasingInFileNamesbooleanDefault: false

Requires all imports to use the exact casing of the referenced file name. Prevents bugs that only appear on case-sensitive filesystems (Linux) but not on case-insensitive ones (macOS, Windows). Catches `import Foo from "./foo"` when the file is actually `Foo.ts`.

"forceConsistentCasingInFileNames": true
skipLibCheckbooleanDefault: false

Skips type checking of all `.d.ts` declaration files (yours and those from npm packages). Prevents errors from incorrect or conflicting third-party type definitions that you cannot fix. Significantly speeds up compilation. Recommended in almost every application.

"skipLibCheck": true

⚠ Pitfall This also skips checking your own `.d.ts` files. If you maintain a library, keep `skipLibCheck: false` in the library's tsconfig but use `true` in consumer apps.

experimentalDecoratorsbooleanDefault: false

Enables support for the legacy decorator syntax (Stage 2 decorators, TypeScript's original implementation). Required for Angular, NestJS, TypeORM, and other frameworks that use `@Decorator` syntax. Note: TypeScript 5.0 added support for the official TC39 decorator standard separately.

"experimentalDecorators": true
emitDecoratorMetadatabooleanDefault: false

Emits design-time type metadata for declarations that have decorators. Required for dependency injection containers that use reflection (NestJS, InversifyJS). Requires `experimentalDecorators: true` and the `reflect-metadata` polyfill at runtime.

"emitDecoratorMetadata": true
JSX(3)
jsxstringDefault: undefined (must be set for JSX)

Controls how JSX syntax is transformed. `"react-jsx"` (React 17+): uses the automatic runtime, no need to import React. `"react"` (legacy): requires `import React from "react"` in every JSX file. `"preserve"`: leaves JSX for the bundler. `"react-native"`: like preserve but outputs `.js` extension.

"jsx": "react-jsx"
jsxImportSourcestringDefault: "react"TS 4.1

Specifies the module that provides `jsx` and `jsxs` factory functions when using `"jsx": "react-jsx"`. Set to `"preact"` for Preact, `"solid-js"` for SolidJS, `"vue"` for Vue 3, etc. Can be overridden per-file with `/** @jsxImportSource preact */`.

"jsxImportSource": "preact"
jsxFactorystringDefault: "React.createElement"

Specifies the function to use for JSX element creation when using `"jsx": "react"` (the legacy transform). Change to `"h"` for Preact, `"React.createElement"` is the React default. This is irrelevant when using the new `"react-jsx"` transform.

"jsxFactory": "h"
Paths(3)
baseUrlstringDefault: undefined

Sets the base directory for resolving non-relative module names. Set to `"."` (project root) or `"./src"` to enable bare imports like `import Button from "components/Button"` instead of `"../../components/Button"`. Usually paired with `paths`.

"baseUrl": "."

⚠ Pitfall TypeScript handles type resolution only. Your bundler (Vite `resolve.alias`, webpack `resolve.alias`) must also be configured with matching paths for the imports to work at runtime.

pathsRecord<string, string[]>Default: undefined

Maps module name patterns to locations. Enables path aliases like `@/*` → `./src/*`. Each pattern maps to an array of fallback locations. Requires `baseUrl` to be set.

"paths": { "@/*": ["./src/*"] }

⚠ Pitfall `paths` is type-checking only — TypeScript will not rewrite import paths in emitted files. Configure matching aliases in your bundler for runtime resolution.

rootDirsstring[]Default: undefined

Tells TypeScript to treat multiple directories as if they were merged into a single virtual root. Useful in monorepos or build systems where files from multiple directories are combined at runtime. Allows relative imports between these directories.

"rootDirs": ["./src", "./generated"]
Projects(3)
compositebooleanDefault: false

Enables project references, allowing `tsc --build` to rebuild only the changed packages in a multi-package repository. Requires `declaration: true` and creates a `.tsbuildinfo` cache file. The cornerstone of TypeScript monorepo incremental builds.

"composite": true
incrementalbooleanDefault: true when composite; otherwise false

Saves build information to a `.tsbuildinfo` file so subsequent builds can skip recompiling unchanged files. Significantly speeds up TypeScript compilation in large projects. Add `.tsbuildinfo` to `.gitignore`.

"incremental": true
tsBuildInfoFilestringDefault: ".tsbuildinfo" in outDir

Specifies the path for the `.tsbuildinfo` incremental build cache file. Change this when building multiple tsconfigs that might write to the same default location, or when storing the cache in a CI-specific directory.

"tsBuildInfoFile": "./.tsbuildinfo"

What this tool does

Searchable reference for every important tsconfig.json compiler option. Covers seven categories used in real projects every day. Type-checking: strict (the umbrella flag), noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, useUnknownInCatchVariables, noUnusedLocals, noUnusedParameters, noImplicitReturns, noFallthroughCasesInSwitch, exactOptionalPropertyTypes (TS 4.4), noUncheckedIndexedAccess (TS 4.1), noPropertyAccessFromIndexSignature. Modules: module (CommonJS / NodeNext / ESNext), moduleResolution (bundler, NodeNext, node10), resolveJsonModule, allowImportingTsExtensions (TS 5.0), allowJs, checkJs, verbatimModuleSyntax (TS 5.0), moduleDetection (TS 4.7). Emit: target, lib, outDir, rootDir, declaration, declarationMap, sourceMap, noEmit, emitDeclarationOnly, removeComments, importHelpers, downlevelIteration. Interop: esModuleInterop, allowSyntheticDefaultImports, isolatedModules, forceConsistentCasingInFileNames, skipLibCheck, experimentalDecorators, emitDecoratorMetadata. JSX: jsx (react-jsx / preserve / react-native), jsxImportSource. Paths: baseUrl, paths, rootDirs. Projects: composite, incremental, tsBuildInfoFile. Every entry shows the type, default value, bilingual EN/ZH description, a copy-ready JSON snippet, and a pitfall note where one exists. Search filters across option name, description, snippet, and pitfall. Category chips scope to any single group. 100% client-side, works offline and behind a corporate proxy.

Tool details

Input
Text
The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
Output
Live result + Copy + Preview
The result area focuses on usable output, with copy, download, or preview actions when supported.
Privacy
Browser-side processing
The main tool logic does not call an external API, so inputs normally stay in the current tab.
Save / share
Shareable URL state
Key settings are encoded in the URL so another person can reopen the same setup.
Performance budget
Initial JS <= 30 KB
No WASM budget is declared, keeping the tool quick to open on mobile.
Best fit
Developer & DevOps · Developer
Category and role tags drive related tools, internal links, and quick fit checks.

How to use

  1. 1. Input

    Paste or drop your content into the tool panel.

  2. 2. Process

    Click the button. All processing is local in your browser.

  3. 3. Copy / Download

    Copy the result or download to disk in one click.

How TypeScript Config Cheatsheet fits into your work

Use it in the small gaps between coding, reviewing, debugging, and shipping.

Developer jobs

  • Formatting, validating, shrinking, or inspecting code-adjacent text.
  • Preparing snippets for documentation, tickets, commits, or handoff.
  • Checking a small payload quickly without switching tools.

Developer checks

  • Run irreversible transforms like minify or obfuscate on a copy.
  • Keep secrets out of pasted snippets unless the tool explicitly stays local.
  • Use your normal tests or linter before shipping transformed code.

Good next steps

These links move the current task into a more complete workflow.

  1. 1 TypeScript Cheatsheet TypeScript cheat sheet — 100+ snippets for types, generics, utility types, narrowing, async patterns. Open
  2. 2 npm / yarn / pnpm Cheatsheet npm / yarn / pnpm cheat sheet — 80+ commands across init, install, scripts, publish, with cross-tool comparison. Open
  3. 3 package.json Cheatsheet package.json field reference — 55+ fields explained with real examples, bilingual, searchable. Open

Real-world use cases

  • Setting up strict type checking on a new project

    You're starting a new TypeScript project and want to enable all strict checks without having to remember every individual flag. The cheatsheet shows that `"strict": true` enables seven checks at once, and explains exactly what each sub-flag catches — so you understand why strictNullChecks forces null-handling and why exactOptionalPropertyTypes is stricter still.

  • Configuring TypeScript for a Vite + React project

    Your new Vite project compiles TypeScript but the tsconfig template is a wall of options you don't fully understand. You look up `moduleResolution: bundler` and learn it's required for Vite, find that `noEmit: true` is correct because Vite handles compilation, and confirm that `allowImportingTsExtensions` lets you import `.ts` files directly.

  • Publishing an npm library with full type support

    You want library consumers to get type inference when they use your package. The cheatsheet shows `declaration: true` emits the `.d.ts` files they need, `declarationMap: true` lets them jump to your TypeScript source, and `emitDeclarationOnly: true` means TypeScript handles types while your bundler handles the JavaScript.

  • Debugging "Cannot find module" or "paths not working" errors

    Your `@/` alias works in Vite but TypeScript reports "Cannot find module." You look up `paths` and see the pitfall: TypeScript only handles the type-checking side — your bundler needs matching aliases too. You add `resolve.alias` to your vite.config.ts and the errors disappear.

Common pitfalls

  • Using `"moduleResolution": "node"` with a Vite/esbuild project — causes subtle module-not-found errors for packages with `exports` fields. Use `"bundler"` instead.

  • Setting `paths` in tsconfig but not configuring matching aliases in the bundler — TypeScript is happy but the app will crash at runtime.

  • Using `noEmit: true` and `emitDeclarationOnly: true` together — `noEmit` wins, nothing is emitted. Pick one.

FAQ

Tool combos

Folks in your role tend to reach for these alongside this tool.

Made by Toolora · 100% client-side · Updated 2026-07-01