TypeScript Reference ยท tsconfig: Projects, Files and Watch Options
Recommended tsconfig presets
Starter tsconfig.json presets for a Node.js app, a bundled browser app and a published library, with notes on why each option is set.
Most projects need one of three configurations. These presets are starting points, not rules: they set the options that matter for the situation and leave the rest at their defaults. Recent TypeScript releases changed some defaults (for example, turning strict checking on and loading fewer ambient @types packages by default), so the presets state important options explicitly, which keeps them working across versions.
All three presets assume modern syntax and type-check only what is under src.
Try it
Each preset is typed here so you can see the options side by side; the second example compares them.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Presets
Node.js application (compiled with tsc or run with a TypeScript-aware runtime):
{ "compilerOptions": { "target": "es2024", "module": "nodenext", "moduleResolution": "nodenext", "strict": true, "types": ["node"], "outDir": "dist", "rootDir": "src", "verbatimModuleSyntax": true, "skipLibCheck": true }, "include": ["src"] }
Browser application built by a bundler (the bundler emits code, TypeScript only checks):
{ "compilerOptions": { "target": "es2022", "module": "esnext", "moduleResolution": "bundler", "lib": ["es2022", "dom", "dom.iterable"], "strict": true, "noEmit": true, "isolatedModules": true, "verbatimModuleSyntax": true, "skipLibCheck": true }, "include": ["src"] }
Published library (ships JavaScript plus declarations):
{ "compilerOptions": { "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "strict": true, "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "dist", "rootDir": "src", "verbatimModuleSyntax": true }, "include": ["src"] }
Usage notes
- Why
nodenextfor Node. It matches how Node actually loads files, including file extensions in relative imports andpackage.jsonexports. - Why
bundlerfor bundled apps. It allows extensionless imports andexports, as bundlers do, without Node's stricter rules. - Libraries skip
skipLibCheck. It hides errors in your dependencies' declarations, but a library should check what it publishes; add it only to applications. - Add checks by need. Many teams add
noUncheckedIndexedAccess,exactOptionalPropertyTypesandnoImplicitOverrideon top. - Share a base. In a monorepo, put common options in
tsconfig.base.jsonandextendsit from each project. - Check what you get with
tsc --showConfig, which prints the resolved configuration.
Related
- strict
- module
- moduleResolution
- composite
- Tutorial: tsconfig, Node and TypeScript