or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-tsconfig--node18

A base TSConfig for working with Node 18.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@tsconfig/node18@2.0.x

To install, run

npx @tessl/cli install tessl/npm-tsconfig--node18@2.0.0

index.mddocs/

@tsconfig/node18

@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.

Package Information

  • Package Name: @tsconfig/node18
  • Package Type: npm
  • Language: TypeScript Configuration (JSON)
  • Installation: npm install --save-dev @tsconfig/node18

Core Usage

Installation

npm install --save-dev @tsconfig/node18

Or with yarn:

yarn add --dev @tsconfig/node18

Basic Usage

Add to your tsconfig.json:

{
  "extends": "@tsconfig/node18/tsconfig.json"
}

Architecture

@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:

  • Node.js 18 Compatibility: Targets ES2022 and uses ES2023 libraries that are fully supported in Node.js 18
  • Modern Module System: Uses Node16 module resolution for proper ESM/CommonJS interoperability
  • Strict Type Safety: Enables all strict type checking options for better code quality
  • Developer Experience: Includes sensible defaults that work out-of-the-box for most Node.js projects

Capabilities

TypeScript Configuration Extension

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:

Compiler Options

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"
  }
}

Configuration Properties

Schema Validation

  • $schema: JSON schema reference for TypeScript configuration validation
  • Value: "https://json.schemastore.org/tsconfig"

Metadata

  • display: Human-readable name for the configuration
  • Value: "Node 18"
  • _version: Internal version tracking for the configuration
  • Value: "2.0.0"

Compiler Options Details

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": true

Enables all strict type checking options including strictNullChecks, strictFunctionTypes, and others.

Module Interoperability

"esModuleInterop": true

Enables seamless interoperability between ES modules and CommonJS modules.

Performance Optimization

"skipLibCheck": true

Skips type checking of declaration files (.d.ts) to improve compilation performance.

File System Consistency

"forceConsistentCasingInFileNames": true

Ensures consistent file name casing across different operating systems.

Module Resolution Strategy

"moduleResolution": "node"

Uses Node.js-style module resolution algorithm for finding imported modules.

Configuration Inheritance

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"
  }
}

Package Structure

The npm package contains the following structure:

Configuration File

  • Path: tsconfig.json (package root)
  • Contains the complete TypeScript configuration object

Package Metadata

  • Standard npm package.json with repository information
  • MIT license
  • Part of the @tsconfig organization scope

Usage Examples

Basic Node.js Project

{
  "extends": "@tsconfig/node18/tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

Express.js Application

{
  "extends": "@tsconfig/node18/tsconfig.json",
  "compilerOptions": {
    "outDir": "./build",
    "rootDir": "./src",
    "resolveJsonModule": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "build", "**/*.test.ts"]
}

Combined with Strictest Configuration

{
  "extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"],
  "compilerOptions": {
    "outDir": "./dist"
  }
}

Library Development

{
  "extends": "@tsconfig/node18/tsconfig.json",
  "compilerOptions": {
    "outDir": "./lib",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["**/*.test.ts", "**/*.spec.ts"]
}

Error Handling

Configuration Resolution Errors

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.

Version Compatibility

This configuration requires TypeScript 4.1+ for proper Node16 module resolution support. Earlier versions may not support all configuration options.

Integration with Development Tools

VS Code

VS Code will automatically use the extended configuration for IntelliSense and error checking once the package is installed and referenced in tsconfig.json.

Build Tools

Compatible with all TypeScript build tools including:

  • tsc (TypeScript compiler)
  • ts-node (TypeScript execution)
  • webpack with ts-loader
  • esbuild
  • swc

Related Packages

Part 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