or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md

index.mddocs/

0

# @tsconfig/node18

1

2

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

3

4

## Package Information

5

6

- **Package Name**: @tsconfig/node18

7

- **Package Type**: npm

8

- **Language**: TypeScript Configuration (JSON)

9

- **Installation**: `npm install --save-dev @tsconfig/node18`

10

11

## Core Usage

12

13

### Installation

14

15

```bash

16

npm install --save-dev @tsconfig/node18

17

```

18

19

Or with yarn:

20

21

```bash

22

yarn add --dev @tsconfig/node18

23

```

24

25

### Basic Usage

26

27

Add to your `tsconfig.json`:

28

29

```json

30

{

31

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

32

}

33

```

34

35

## Architecture

36

37

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

38

39

The configuration follows these design principles:

40

- **Node.js 18 Compatibility**: Targets ES2022 and uses ES2023 libraries that are fully supported in Node.js 18

41

- **Modern Module System**: Uses Node16 module resolution for proper ESM/CommonJS interoperability

42

- **Strict Type Safety**: Enables all strict type checking options for better code quality

43

- **Developer Experience**: Includes sensible defaults that work out-of-the-box for most Node.js projects

44

45

## Capabilities

46

47

### TypeScript Configuration Extension

48

49

The primary capability is providing a ready-to-use TypeScript configuration via the npm package extension mechanism.

50

51

```json { .api }

52

{

53

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

54

}

55

```

56

57

This extends your project's `tsconfig.json` with the following configuration:

58

59

### Compiler Options

60

61

The configuration provides the following compiler options optimized for Node.js 18:

62

63

```json { .api }

64

{

65

"$schema": "https://json.schemastore.org/tsconfig",

66

"display": "Node 18",

67

"_version": "2.0.0",

68

"compilerOptions": {

69

"lib": ["es2023"],

70

"module": "Node16",

71

"target": "es2022",

72

"strict": true,

73

"esModuleInterop": true,

74

"skipLibCheck": true,

75

"forceConsistentCasingInFileNames": true,

76

"moduleResolution": "node"

77

}

78

}

79

```

80

81

#### Configuration Properties

82

83

**Schema Validation**

84

- `$schema`: JSON schema reference for TypeScript configuration validation

85

- Value: `"https://json.schemastore.org/tsconfig"`

86

87

**Metadata**

88

- `display`: Human-readable name for the configuration

89

- Value: `"Node 18"`

90

- `_version`: Internal version tracking for the configuration

91

- Value: `"2.0.0"`

92

93

#### Compiler Options Details

94

95

**Library Support**

96

```json { .api }

97

"lib": ["es2023"]

98

```

99

Specifies ES2023 library features available during compilation, providing access to the latest JavaScript features supported by Node.js 18.

100

101

**Module System**

102

```json { .api }

103

"module": "Node16"

104

```

105

Configures TypeScript to generate Node16-compatible module code, supporting both ESM and CommonJS with proper resolution.

106

107

**Compilation Target**

108

```json { .api }

109

"target": "es2022"

110

```

111

Sets the ECMAScript target to ES2022, ensuring compatibility with Node.js 18's JavaScript engine.

112

113

**Type Checking Strictness**

114

```json { .api }

115

"strict": true

116

```

117

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

118

119

**Module Interoperability**

120

```json { .api }

121

"esModuleInterop": true

122

```

123

Enables seamless interoperability between ES modules and CommonJS modules.

124

125

**Performance Optimization**

126

```json { .api }

127

"skipLibCheck": true

128

```

129

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

130

131

**File System Consistency**

132

```json { .api }

133

"forceConsistentCasingInFileNames": true

134

```

135

Ensures consistent file name casing across different operating systems.

136

137

**Module Resolution Strategy**

138

```json { .api }

139

"moduleResolution": "node"

140

```

141

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

142

143

### Configuration Inheritance

144

145

TypeScript allows extending configurations using the `extends` property:

146

147

```typescript { .api }

148

interface TSConfigExtends {

149

extends: string | string[];

150

}

151

```

152

153

**Single Configuration Extension**

154

```json { .api }

155

{

156

"extends": "@tsconfig/node18/tsconfig.json",

157

"compilerOptions": {

158

"outDir": "./dist"

159

}

160

}

161

```

162

163

**Multiple Configuration Extension** (TypeScript 5.0+)

164

```json { .api }

165

{

166

"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"],

167

"compilerOptions": {

168

"outDir": "./dist"

169

}

170

}

171

```

172

173

### Package Structure

174

175

The npm package contains the following structure:

176

177

**Configuration File**

178

- Path: `tsconfig.json` (package root)

179

- Contains the complete TypeScript configuration object

180

181

**Package Metadata**

182

- Standard npm package.json with repository information

183

- MIT license

184

- Part of the @tsconfig organization scope

185

186

## Usage Examples

187

188

### Basic Node.js Project

189

190

```json

191

{

192

"extends": "@tsconfig/node18/tsconfig.json",

193

"compilerOptions": {

194

"outDir": "./dist",

195

"rootDir": "./src"

196

},

197

"include": ["src/**/*"],

198

"exclude": ["node_modules", "dist"]

199

}

200

```

201

202

### Express.js Application

203

204

```json

205

{

206

"extends": "@tsconfig/node18/tsconfig.json",

207

"compilerOptions": {

208

"outDir": "./build",

209

"rootDir": "./src",

210

"resolveJsonModule": true

211

},

212

"include": ["src/**/*"],

213

"exclude": ["node_modules", "build", "**/*.test.ts"]

214

}

215

```

216

217

### Combined with Strictest Configuration

218

219

```json

220

{

221

"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node18/tsconfig"],

222

"compilerOptions": {

223

"outDir": "./dist"

224

}

225

}

226

```

227

228

### Library Development

229

230

```json

231

{

232

"extends": "@tsconfig/node18/tsconfig.json",

233

"compilerOptions": {

234

"outDir": "./lib",

235

"declaration": true,

236

"declarationMap": true,

237

"sourceMap": true

238

},

239

"include": ["src/**/*"],

240

"exclude": ["**/*.test.ts", "**/*.spec.ts"]

241

}

242

```

243

244

## Error Handling

245

246

### Configuration Resolution Errors

247

248

If the package is not installed, TypeScript will throw an error:

249

```

250

File '@tsconfig/node18/tsconfig.json' not found.

251

```

252

253

Solution: Install the package as a dev dependency.

254

255

### Version Compatibility

256

257

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

258

259

## Integration with Development Tools

260

261

### VS Code

262

263

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

264

265

### Build Tools

266

267

Compatible with all TypeScript build tools including:

268

- `tsc` (TypeScript compiler)

269

- `ts-node` (TypeScript execution)

270

- `webpack` with ts-loader

271

- `esbuild`

272

- `swc`

273

274

## Related Packages

275

276

Part of the @tsconfig ecosystem:

277

- `@tsconfig/recommended` - General recommended settings

278

- `@tsconfig/strictest` - Maximum type safety

279

- `@tsconfig/node16` - Node.js 16 optimized

280

- `@tsconfig/node20` - Node.js 20 optimized

281

- `@tsconfig/esm` - ES modules focused