A base TSConfig for working with Node 18.
npx @tessl/cli install tessl/npm-tsconfig--node18@2.0.0@tsconfig/node18 provides a pre-configured TypeScript configuration optimized for Node.js 18 environments. It includes compiler options that target ES2022, use Node16 module resolution, enable strict type checking, and support ES2023 libraries. Key features include modern Node.js compatibility, strict type safety, optimized module resolution, and seamless ESM/CommonJS interoperability.
npm install --save-dev @tsconfig/node18npm install --save-dev @tsconfig/node18Or with yarn:
yarn add --dev @tsconfig/node18Add to your tsconfig.json:
{
"extends": "@tsconfig/node18/tsconfig.json"
}@tsconfig/node18 is a configuration package that provides a curated set of TypeScript compiler options specifically tuned for Node.js 18 runtime environments. It eliminates the need for developers to manually research and configure TypeScript settings for Node.js 18 compatibility.
The configuration follows these design principles:
The primary capability is providing a ready-to-use TypeScript configuration via the npm package extension mechanism.
{
"extends": "@tsconfig/node18/tsconfig.json"
}This extends your project's tsconfig.json with the following configuration:
The configuration provides the following compiler options optimized for Node.js 18:
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 18",
"_version": "2.0.0",
"compilerOptions": {
"lib": ["es2023"],
"module": "Node16",
"target": "es2022",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node"
}
}Schema Validation
$schema: JSON schema reference for TypeScript configuration validation"https://json.schemastore.org/tsconfig"Metadata
display: Human-readable name for the configuration"Node 18"_version: Internal version tracking for the configuration"2.0.0"Library Support
"lib": ["es2023"]Specifies ES2023 library features available during compilation, providing access to the latest JavaScript features supported by Node.js 18.
Module System
"module": "Node16"Configures TypeScript to generate Node16-compatible module code, supporting both ESM and CommonJS with proper resolution.
Compilation Target
"target": "es2022"Sets the ECMAScript target to ES2022, ensuring compatibility with Node.js 18's JavaScript engine.
Type Checking Strictness
"strict": trueEnables all strict type checking options including strictNullChecks, strictFunctionTypes, and others.
Module Interoperability
"esModuleInterop": trueEnables seamless interoperability between ES modules and CommonJS modules.
Performance Optimization
"skipLibCheck": trueSkips type checking of declaration files (.d.ts) to improve compilation performance.
File System Consistency
"forceConsistentCasingInFileNames": trueEnsures consistent file name casing across different operating systems.
Module Resolution Strategy
"moduleResolution": "node"Uses Node.js-style module resolution algorithm for finding imported modules.
TypeScript allows extending configurations using the extends property:
interface TSConfigExtends {
extends: string | string[];
}Single Configuration Extension
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
}
}Multiple Configuration Extension (TypeScript 5.0+)
{
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"],
"compilerOptions": {
"outDir": "./dist"
}
}The npm package contains the following structure:
Configuration File
tsconfig.json (package root)Package Metadata
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./build",
"rootDir": "./src",
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build", "**/*.test.ts"]
}{
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"],
"compilerOptions": {
"outDir": "./dist"
}
}{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["**/*.test.ts", "**/*.spec.ts"]
}If the package is not installed, TypeScript will throw an error:
File '@tsconfig/node18/tsconfig.json' not found.Solution: Install the package as a dev dependency.
This configuration requires TypeScript 4.1+ for proper Node16 module resolution support. Earlier versions may not support all configuration options.
VS Code will automatically use the extended configuration for IntelliSense and error checking once the package is installed and referenced in tsconfig.json.
Compatible with all TypeScript build tools including:
tsc (TypeScript compiler)ts-node (TypeScript execution)webpack with ts-loaderesbuildswcPart of the @tsconfig ecosystem:
@tsconfig/recommended - General recommended settings@tsconfig/strictest - Maximum type safety@tsconfig/node16 - Node.js 16 optimized@tsconfig/node20 - Node.js 20 optimized@tsconfig/esm - ES modules focused