base
> Strict base TypeScript configuration with modern defaults. No include/exclude patterns, so you control what gets compiled.
✨ Features
Section titled “✨ Features”- 🔒 Strict Mode:
strictplus extra safety flags - 🚀 Modern Defaults: ES2022 target with NodeNext modules
- 🎯 Flexible: no file patterns imposed
- 🗺️ Source Maps: source and declaration maps enabled
📦 Installation
Section titled “📦 Installation”npm install --save-dev @jmlweb/tsconfig-base typescript🚀 Quick Start
Section titled “🚀 Quick Start”{ "extends": "@jmlweb/tsconfig-base", "compilerOptions": { "outDir": "./dist", "rootDir": "./src" }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"]}💡 Examples
Section titled “💡 Examples”Library with declarations in a monorepo
Section titled “Library with declarations in a monorepo”{ "extends": "@jmlweb/tsconfig-base", "compilerOptions": { "outDir": "./dist", "rootDir": "./src", "composite": true }, "include": ["src/**/*"], "exclude": ["node_modules", "dist", "**/*.test.ts"]}Relaxing options
Section titled “Relaxing options”{ "extends": "@jmlweb/tsconfig-base", "compilerOptions": { "target": "ES2020", "noUncheckedIndexedAccess": false }, "include": ["src/**/*"]}📋 Configuration Details
Section titled “📋 Configuration Details”| 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.
Common issues
Section titled “Common issues”- “Relative import paths need explicit file extensions”:
NodeNextrequires.jsextensions in relative imports (import { foo } from './bar.js'), or switch to bundler resolution (see below). module/moduleResolutionmismatch: override both together.T | undefinedonobj[key]: caused bynoUncheckedIndexedAccess; use?.or an explicit check.
🎯 When to Use
Section titled “🎯 When to Use”- ✅ 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.
🔧 Extending the Configuration
Section titled “🔧 Extending the Configuration”Bundler-based resolution (ESM):
{ "extends": "@jmlweb/tsconfig-base", "compilerOptions": { "module": "ESNext", "moduleResolution": "bundler" }}CommonJS:
{ "extends": "@jmlweb/tsconfig-base", "compilerOptions": { "module": "CommonJS", "moduleResolution": "node" }}📝 Usage with Scripts
Section titled “📝 Usage with Scripts”{ "scripts": { "build": "tsc", "typecheck": "tsc --noEmit" }}npm run typecheck📋 Requirements
Section titled “📋 Requirements”- Node.js >= 22.12.0
- TypeScript >= 5.0.0
📦 Peer Dependencies
Section titled “📦 Peer Dependencies”None declared. Install typescript (>= 5.0.0) in your project.
🔗 Related Packages
Section titled “🔗 Related Packages”@jmlweb/tsconfig-node- extends this config for Node.js and CLIs@jmlweb/tsconfig-react- extends this config for React@jmlweb/tsconfig-astro- extends this config for Astro@jmlweb/oxlint-config-base- Oxlint configuration for TypeScript projects (recommended)@jmlweb/oxfmt-config-base- Oxfmt configuration (recommended)
🔄 Migration Guide
Section titled “🔄 Migration Guide”1.x → 2.0.0
Section titled “1.x → 2.0.0”Breaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).
- Upgrade Node.js to 22.12.0 or later.
- Update the package:
npm install --save-dev @jmlweb/tsconfig-base@^2.0.0.
The compilerOptions are unchanged. See the Changelog.
📄 License
Section titled “📄 License”MIT