Skip to content

base

npm version License: MIT Node.js TypeScript

> Strict base TypeScript configuration with modern defaults. No include/exclude patterns, so you control what gets compiled.

  • 🔒 Strict Mode: strict plus extra safety flags
  • 🚀 Modern Defaults: ES2022 target with NodeNext modules
  • 🎯 Flexible: no file patterns imposed
  • 🗺️ Source Maps: source and declaration maps enabled
Terminal window
npm install --save-dev @jmlweb/tsconfig-base typescript
{
"extends": "@jmlweb/tsconfig-base",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
{
"extends": "@jmlweb/tsconfig-base",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"composite": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}
{
"extends": "@jmlweb/tsconfig-base",
"compilerOptions": {
"target": "ES2020",
"noUncheckedIndexedAccess": false
},
"include": ["src/**/*"]
}
Option Value Description
strict true All strict type checking options
target ES2022 Modern JavaScript output
module NodeNext Node.js ESM/CJS module system
moduleResolution NodeNext Node.js module resolution
esModuleInterop true CommonJS/ESM interoperability
skipLibCheck true Skip type checking of declaration files
forceConsistentCasingInFileNames true Enforce consistent file name casing
declaration true Generate .d.ts files
declarationMap true Generate maps for .d.ts files
sourceMap true Generate source maps
noUncheckedIndexedAccess true Add undefined to index signature access
noImplicitOverride true Require the override keyword
noPropertyAccessFromIndexSignature true Require bracket notation for index signatures
exactOptionalPropertyTypes true Differentiate undefined from optional
noFallthroughCasesInSwitch true Report fallthrough cases in switch
isolatedModules true Ensure transpiler compatibility
verbatimModuleSyntax true Enforce explicit type imports/exports
resolveJsonModule true Allow importing JSON files

You must set include, exclude and (recommended) outDir/rootDir yourself.

  • “Relative import paths need explicit file extensions”: NodeNext requires .js extensions in relative imports (import { foo } from './bar.js'), or switch to bundler resolution (see below).
  • module/moduleResolution mismatch: override both together.
  • T | undefined on obj[key]: caused by noUncheckedIndexedAccess; use ?. or an explicit check.
  • ✅ Strict TypeScript for Node.js libraries and services
  • ✅ A foundation for framework-specific configs
  • ✅ Projects that want full control over file patterns

Not for the browser or JSX: use @jmlweb/tsconfig-react. Not for Node.js without DOM types in a bundler-free setup: use @jmlweb/tsconfig-node.

Bundler-based resolution (ESM):

{
"extends": "@jmlweb/tsconfig-base",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler"
}
}

CommonJS:

{
"extends": "@jmlweb/tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "node"
}
}
{
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit"
}
}
Terminal window
npm run typecheck
  • Node.js >= 22.12.0
  • TypeScript >= 5.0.0

None declared. Install typescript (>= 5.0.0) in your project.

Breaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).

  1. Upgrade Node.js to 22.12.0 or later.
  2. Update the package: npm install --save-dev @jmlweb/tsconfig-base@^2.0.0.

The compilerOptions are unchanged. See the Changelog.

MIT