Skip to content

TypeScript tsconfig.json Reference

tsconfig.json is the configuration file for the TypeScript compiler. It controls how TypeScript compiles your code, which files are included, and what checks are performed.

{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"sourceMap": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
OptionPurposeRecommendation
targetJS output versionES2022
moduleModule systemESNext
strictAll strict checkstrue
outDirOutput directory./dist
rootDirSource directory./src
declarationGenerate .d.ts filestrue for libraries

React App:

{
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["ES2022", "DOM", "DOM.Iterable"]
}
}

Node.js App:

{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"types": ["node"]
}
}

Easy: What is tsconfig.json used for?

Medium: What does strict: true enable?

Hard: How is configuration different for React vs Node.js projects?