TypeScript tsconfig.json Reference
tsconfig.json Reference
Section titled “tsconfig.json Reference”What is tsconfig.json?
Section titled “What is tsconfig.json?”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.
Recommended Configuration
Section titled “Recommended Configuration”{ "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"]}Key Options Explained
Section titled “Key Options Explained”| Option | Purpose | Recommendation |
|---|---|---|
target | JS output version | ES2022 |
module | Module system | ESNext |
strict | All strict checks | true |
outDir | Output directory | ./dist |
rootDir | Source directory | ./src |
declaration | Generate .d.ts files | true for libraries |
Project-Specific Configs
Section titled “Project-Specific Configs”React App:
{ "compilerOptions": { "jsx": "react-jsx", "lib": ["ES2022", "DOM", "DOM.Iterable"] }}Node.js App:
{ "compilerOptions": { "module": "NodeNext", "moduleResolution": "NodeNext", "types": ["node"] }}Interview Questions
Section titled “Interview Questions”Easy: What is tsconfig.json used for?
Medium: What does strict: true enable?
Hard: How is configuration different for React vs Node.js projects?