A base TSConfig for working with Node 14.
npx @tessl/cli install tessl/npm-tsconfig--node14@14.1.00
# @tsconfig/node14
1
2
A base TypeScript configuration optimized for Node.js 14 runtime environment. This package provides sensible compiler defaults for projects targeting Node.js 14, including ES2020 language features, node16 module resolution, and strict type checking enabled.
3
4
## Package Information
5
6
- **Package Name**: @tsconfig/node14
7
- **Package Type**: npm
8
- **Language**: JSON (TypeScript configuration)
9
- **Installation**: `npm install --save-dev @tsconfig/node14` or `yarn add --dev @tsconfig/node14`
10
11
## Core Imports
12
13
This package is not imported as a module but rather extended through TypeScript's configuration system:
14
15
```json
16
{
17
"extends": "@tsconfig/node14/tsconfig.json"
18
}
19
```
20
21
## Basic Usage
22
23
Create or update your project's `tsconfig.json` file to extend this base configuration:
24
25
```json
26
{
27
"extends": "@tsconfig/node14/tsconfig.json",
28
"compilerOptions": {
29
// Your custom overrides here
30
"outDir": "./dist",
31
"rootDir": "./src"
32
},
33
"include": ["src/**/*"],
34
"exclude": ["node_modules", "dist"]
35
}
36
```
37
38
The base configuration will provide all the Node.js 14 optimized compiler options, which you can then customize with additional options or overrides as needed.
39
40
## Capabilities
41
42
### Base TypeScript Configuration
43
44
Provides a complete TypeScript compiler configuration optimized for Node.js 14 runtime with modern JavaScript features and strict type checking.
45
46
```json { .api }
47
{
48
"$schema": "https://json.schemastore.org/tsconfig",
49
"display": "Node 14",
50
"_version": "14.1.0",
51
"compilerOptions": {
52
"lib": ["es2020"],
53
"module": "node16",
54
"target": "es2020",
55
"strict": true,
56
"esModuleInterop": true,
57
"skipLibCheck": true,
58
"moduleResolution": "node16"
59
}
60
}
61
```
62
63
**Configuration Properties:**
64
65
- **$schema**: `"https://json.schemastore.org/tsconfig"` - JSON schema for IDE validation and autocomplete
66
- **display**: `"Node 14"` - Human-readable name for this configuration
67
- **_version**: `"14.1.0"` - Internal version tracking for the configuration
68
- **compilerOptions**: Core TypeScript compiler settings
69
- **lib**: `["es2020"]` - Available ECMAScript library features (ES2020 APIs)
70
- **module**: `"node16"` - Module system (Node.js 16+ style module resolution with package.json "type" support)
71
- **target**: `"es2020"` - JavaScript output target (ES2020 syntax and features)
72
- **strict**: `true` - Enables all strict type-checking options for better code quality
73
- **esModuleInterop**: `true` - Enables seamless interoperability between CommonJS and ES modules
74
- **skipLibCheck**: `true` - Skips type checking of declaration files for faster compilation
75
- **moduleResolution**: `"node16"` - Uses Node.js 16+ module resolution algorithm
76
77
### Configuration Extension
78
79
The configuration is designed to be extended by consumer projects through TypeScript's built-in configuration inheritance system.
80
81
```json { .api }
82
{
83
"extends": "@tsconfig/node14/tsconfig.json"
84
}
85
```
86
87
**Extension Behavior:**
88
- Consumer configurations inherit all compiler options from this base
89
- Consumer can override any inherited option by specifying it in their own `compilerOptions`
90
- Consumer can add additional options not present in the base configuration
91
- Arrays in `compilerOptions` (like `lib`) are replaced entirely, not merged
92
93
**Override Examples:**
94
95
```json
96
{
97
"extends": "@tsconfig/node14/tsconfig.json",
98
"compilerOptions": {
99
// Override target to older version if needed
100
"target": "es2018",
101
// Add additional libraries
102
"lib": ["es2020", "dom"],
103
// Add output directory
104
"outDir": "./build",
105
// Enable source maps for debugging
106
"sourceMap": true
107
}
108
}
109
```
110
111
### Multiple Configuration Extension
112
113
Can be combined with other @tsconfig packages using TypeScript 5.0+ multiple extends feature:
114
115
```json { .api }
116
{
117
"extends": [
118
"@tsconfig/node14/tsconfig.json",
119
"@tsconfig/strictest/tsconfig.json"
120
]
121
}
122
```
123
124
**Combination Rules:**
125
- Later configurations in the array override earlier ones
126
- Each configuration's `compilerOptions` are merged in order
127
- Final configuration is the result of all merged settings
128
129
## Types
130
131
### TypeScript Configuration Schema
132
133
The package provides a JSON configuration file that conforms to the TypeScript configuration schema:
134
135
```typescript { .api }
136
interface TSConfig {
137
/** JSON schema reference for validation */
138
$schema?: string;
139
/** Human-readable display name */
140
display?: string;
141
/** Internal version tracking */
142
_version?: string;
143
/** TypeScript compiler options */
144
compilerOptions?: CompilerOptions;
145
/** Base configurations to extend from */
146
extends?: string | string[];
147
/** Files to include in compilation */
148
include?: string[];
149
/** Files to exclude from compilation */
150
exclude?: string[];
151
/** Specific files to compile */
152
files?: string[];
153
}
154
155
interface CompilerOptions {
156
/** ECMAScript library features to include */
157
lib?: string[];
158
/** Module system to use */
159
module?: string;
160
/** JavaScript output target */
161
target?: string;
162
/** Enable all strict type-checking options */
163
strict?: boolean;
164
/** Enable ES module interoperability */
165
esModuleInterop?: boolean;
166
/** Skip type checking of declaration files */
167
skipLibCheck?: boolean;
168
/** Module resolution strategy */
169
moduleResolution?: string;
170
/** Output directory for compiled files */
171
outDir?: string;
172
/** Root directory of source files */
173
rootDir?: string;
174
/** Generate source maps */
175
sourceMap?: boolean;
176
/** Generate declaration files */
177
declaration?: boolean;
178
/** Other compiler options... */
179
[key: string]: any;
180
}
181
```
182
183
## Node.js 14 Compatibility
184
185
This configuration is specifically optimized for Node.js 14.x runtime environment:
186
187
**Language Features:**
188
- **ES2020**: Full support for ES2020 JavaScript features including optional chaining, nullish coalescing, BigInt, and dynamic imports
189
- **Node.js 14 APIs**: Access to Node.js 14 built-in modules and APIs through ES2020 lib definitions
190
191
**Module Support:**
192
- **node16 Module Resolution**: Modern Node.js module resolution supporting both CommonJS and ES modules
193
- **Package.json "type" Field**: Respects package.json "type" field for determining module format
194
- **Conditional Exports**: Supports package.json "exports" field for conditional module exports
195
196
**Performance Optimizations:**
197
- **skipLibCheck**: Faster compilation by skipping type checking of .d.ts files
198
- **Strict Mode**: Better optimization opportunities through strict type checking
199
200
## Installation and Setup
201
202
### Installation
203
204
Install as a development dependency:
205
206
```bash
207
# npm
208
npm install --save-dev @tsconfig/node14
209
210
# yarn
211
yarn add --dev @tsconfig/node14
212
213
# pnpm
214
pnpm add --save-dev @tsconfig/node14
215
```
216
217
### Project Setup
218
219
1. Create a `tsconfig.json` in your project root:
220
221
```json
222
{
223
"extends": "@tsconfig/node14/tsconfig.json",
224
"compilerOptions": {
225
"outDir": "./dist",
226
"rootDir": "./src"
227
},
228
"include": ["src/**/*"],
229
"exclude": ["node_modules", "dist"]
230
}
231
```
232
233
2. Ensure your project targets Node.js 14 or higher in `package.json`:
234
235
```json
236
{
237
"engines": {
238
"node": ">=14.0.0"
239
}
240
}
241
```
242
243
3. Your TypeScript code can now use ES2020 features and Node.js 14 APIs with full type support.
244
245
## Error Handling
246
247
### Common Configuration Issues
248
249
**Module Resolution Errors:**
250
- Ensure your project structure aligns with the chosen module resolution strategy
251
- Check that package.json "type" field matches your import/export syntax
252
- Verify that dependencies support the selected module format
253
254
**Compilation Errors:**
255
- If targeting older Node.js versions, consider overriding "target" and "lib" options
256
- Some ES2020 features may require additional polyfills in runtime environments
257
- Check that all imported modules are compatible with ES2020 and Node.js 14
258
259
**Type Checking Issues:**
260
- The strict mode settings may reveal previously hidden type errors
261
- Consider gradually enabling strict options if migrating from a looser configuration
262
- Use type assertions or proper typing to resolve strict mode conflicts
263
264
### Configuration Validation
265
266
TypeScript will validate the configuration and report errors for:
267
- Invalid compiler option values
268
- Conflicting option combinations
269
- Missing required dependencies for specific features
270
- Incompatible option combinations with the selected target/module settings