Shared TypeScript configuration for projects targeting Node.js 20 with strict compiler settings
npx @tessl/cli install tessl/npm-sindresorhus--tsconfig@8.0.0@sindresorhus/tsconfig provides a shared TypeScript configuration for projects targeting Node.js 20+ with strict compiler settings. It enforces modern JavaScript features, comprehensive type safety, and best practices for TypeScript development.
npm install --save-dev @sindresorhus/tsconfigThis package exports a TypeScript configuration file that is consumed via the extends property in your project's tsconfig.json:
{
"extends": "@sindresorhus/tsconfig"
}The package export path is defined as:
{
"exports": "./tsconfig.json"
}Create or update your project's tsconfig.json to extend this configuration:
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}The extended configuration will provide strict TypeScript settings optimized for Node.js 20+ development with modern ECMAScript features.
The configuration provides several key areas of TypeScript compiler settings:
Node.js 20+ module system configuration with ESNext targeting and modern module resolution.
{
"compilerOptions": {
"module": "node20",
"moduleResolution": "node16",
"moduleDetection": "force",
"target": "esnext"
}
}DOM and ES2023 library support optimized for Node.js 20 runtime with React JSX compilation capability.
{
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"resolveJsonModule": false,
"jsx": "react-jsx"
}
}Comprehensive output configuration for distribution builds with declaration files and consistent formatting.
{
"compilerOptions": {
"outDir": "${configDir}/distribution",
"declaration": true,
"newLine": "lf",
"stripInternal": true,
"erasableSyntaxOnly": true,
"noEmitOnError": true
}
}Complete strict mode configuration with enhanced error detection and type safety enforcement.
{
"compilerOptions": {
"strict": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedSideEffectImports": true
}
}Additional compiler options for improved development experience and code consistency.
{
"compilerOptions": {
"useDefineForClassFields": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
}
}When extending this configuration, you can override specific settings for your project needs:
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
// Override output directory
"outDir": "./build",
// Add additional libraries
"lib": ["DOM", "DOM.Iterable", "ES2023", "WebWorker"],
// Adjust module detection
"moduleDetection": "auto"
}
}The exported configuration includes all the following compiler options:
{
"compilerOptions": {
"outDir": "${configDir}/distribution",
"module": "node20",
"moduleResolution": "node16",
"moduleDetection": "force",
"target": "esnext",
"lib": ["DOM", "DOM.Iterable", "ES2023"],
"resolveJsonModule": false,
"jsx": "react-jsx",
"declaration": true,
"newLine": "lf",
"stripInternal": true,
"erasableSyntaxOnly": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedSideEffectImports": true,
"noEmitOnError": true,
"useDefineForClassFields": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
}
}