5 min read
•Question 46 of 48mediumWhat are the important tsconfig.json options?
Key TypeScript configuration.
What You'll Learn
- Essential compiler options
- Path configuration
- Recommended settings
Essential Options
data.jsonJSON
{
"compilerOptions": {
// Strict type checking
"strict": true,
// Target JavaScript version
"target": "ES2022",
// Module system
"module": "ESNext",
"moduleResolution": "bundler",
// Output
"outDir": "./dist",
"rootDir": "./src",
// Emit settings
"declaration": true,
"sourceMap": true,
// Interop
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
// Skip lib checking for speed
"skipLibCheck": true
}
}Path Mapping
data.jsonJSON
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@components/*": ["src/components/*"]
}
}
}Include/Exclude
data.jsonJSON
{
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}Modern Recommendations
data.jsonJSON
{
"compilerOptions": {
"strict": true,
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"isolatedModules": true,
"noUncheckedIndexedAccess": true
}
}