What Each Option Does

OptionWhat it does
targetThe JavaScript version to output. ES2022 works in Node.js 18+ and modern browsers.
module, moduleResolutionNodeNext follows how Node.js loads ES modules and CommonJS. For a Vite or webpack app, use "ESNext" and "Bundler".
libWhich built-in type definitions are available. Add "DOM" for browser code.
outDir, rootDirWhere the compiled files go, and where your source files are.
strictTurns on all strict type checks. Strongly recommended.
esModuleInteropMakes importing CommonJS packages with import work smoothly.
skipLibCheckSkips type checking of .d.ts files in node_modules, for faster builds.
forceConsistentCasingInFileNamesCatches imports that differ only in upper/lower case.
resolveJsonModuleLets you import .json files.
declaration, sourceMapWrites .d.ts type files and source maps for debugging.
noUncheckedIndexedAccessTreats array and object lookups as possibly undefined, which prevents many bugs.
include, excludeWhich folders TypeScript checks and which it ignores.

Tips

  • Run npx tsc --init to create a tsconfig.json with every option listed as a comment.
  • Check the compiled settings with npx tsc --showConfig.
  • tsconfig.json may contain comments (it is read as JSONC), but plain JSON like this template works with every tool. Read more in our JSON comments guide, and format a tsconfig.json that has comments with the JSON5 and JSONC Formatter.

Frequently Asked Questions

What is tsconfig.json?

tsconfig.json tells the TypeScript compiler which files to check and how to compile them, for example which JavaScript version to output and how strict to be.

Can tsconfig.json have comments?

Yes. TypeScript reads tsconfig.json as JSONC, so comments and trailing commas are allowed. Other tools may not accept them, so this template is plain JSON.

Should I turn on strict?

Yes, for new projects. strict turns on a group of checks that catch many bugs early, such as values that might be null or undefined.

Related Tools