0
# @sindresorhus/tsconfig
1
2
@sindresorhus/tsconfig provides a shared TypeScript configuration for projects targeting Node.js 20+ with strict compiler settings. It enforces modern JavaScript features, comprehensive type safety, and best practices for TypeScript development.
3
4
## Package Information
5
6
- **Package Name**: @sindresorhus/tsconfig
7
- **Package Type**: npm
8
- **Language**: TypeScript Configuration
9
- **Installation**: `npm install --save-dev @sindresorhus/tsconfig`
10
- **Requirements**: TypeScript 5.5+, Node.js 20+
11
12
## Core Imports
13
14
This package exports a TypeScript configuration file that is consumed via the `extends` property in your project's `tsconfig.json`:
15
16
```json
17
{
18
"extends": "@sindresorhus/tsconfig"
19
}
20
```
21
22
The package export path is defined as:
23
```json
24
{
25
"exports": "./tsconfig.json"
26
}
27
```
28
29
## Basic Usage
30
31
Create or update your project's `tsconfig.json` to extend this configuration:
32
33
```json
34
{
35
"extends": "@sindresorhus/tsconfig",
36
"compilerOptions": {
37
"outDir": "./dist"
38
},
39
"include": ["src/**/*"],
40
"exclude": ["node_modules", "dist"]
41
}
42
```
43
44
The extended configuration will provide strict TypeScript settings optimized for Node.js 20+ development with modern ECMAScript features.
45
46
## Architecture
47
48
The configuration provides several key areas of TypeScript compiler settings:
49
50
- **Module System**: Configured for Node.js 20 with ESNext targeting
51
- **Type Safety**: Comprehensive strict mode settings and error detection
52
- **Output Configuration**: Declaration files, source maps, and output formatting
53
- **Library Support**: DOM and ES2023 libraries with React JSX support
54
- **Development Experience**: Enhanced error reporting and consistency enforcement
55
56
## Capabilities
57
58
### Module Configuration
59
60
Node.js 20+ module system configuration with ESNext targeting and modern module resolution.
61
62
```json { .api }
63
{
64
"compilerOptions": {
65
"module": "node20",
66
"moduleResolution": "node16",
67
"moduleDetection": "force",
68
"target": "esnext"
69
}
70
}
71
```
72
73
### Library and Runtime Support
74
75
DOM and ES2023 library support optimized for Node.js 20 runtime with React JSX compilation capability.
76
77
```json { .api }
78
{
79
"compilerOptions": {
80
"lib": ["DOM", "DOM.Iterable", "ES2023"],
81
"resolveJsonModule": false,
82
"jsx": "react-jsx"
83
}
84
}
85
```
86
87
### Output and Build Configuration
88
89
Comprehensive output configuration for distribution builds with declaration files and consistent formatting.
90
91
```json { .api }
92
{
93
"compilerOptions": {
94
"outDir": "${configDir}/distribution",
95
"declaration": true,
96
"newLine": "lf",
97
"stripInternal": true,
98
"erasableSyntaxOnly": true,
99
"noEmitOnError": true
100
}
101
}
102
```
103
104
### Strict Type Safety Settings
105
106
Complete strict mode configuration with enhanced error detection and type safety enforcement.
107
108
```json { .api }
109
{
110
"compilerOptions": {
111
"strict": true,
112
"noImplicitReturns": true,
113
"noImplicitOverride": true,
114
"noUnusedLocals": true,
115
"noUnusedParameters": true,
116
"noFallthroughCasesInSwitch": true,
117
"noUncheckedIndexedAccess": true,
118
"noPropertyAccessFromIndexSignature": true,
119
"noUncheckedSideEffectImports": true
120
}
121
}
122
```
123
124
### Development and Consistency Settings
125
126
Additional compiler options for improved development experience and code consistency.
127
128
```json { .api }
129
{
130
"compilerOptions": {
131
"useDefineForClassFields": true,
132
"forceConsistentCasingInFileNames": true,
133
"skipLibCheck": true
134
}
135
}
136
```
137
138
## Configuration Override Patterns
139
140
When extending this configuration, you can override specific settings for your project needs:
141
142
```json
143
{
144
"extends": "@sindresorhus/tsconfig",
145
"compilerOptions": {
146
// Override output directory
147
"outDir": "./build",
148
// Add additional libraries
149
"lib": ["DOM", "DOM.Iterable", "ES2023", "WebWorker"],
150
// Adjust module detection
151
"moduleDetection": "auto"
152
}
153
}
154
```
155
156
## Complete Configuration Reference
157
158
The exported configuration includes all the following compiler options:
159
160
```json { .api }
161
{
162
"compilerOptions": {
163
"outDir": "${configDir}/distribution",
164
"module": "node20",
165
"moduleResolution": "node16",
166
"moduleDetection": "force",
167
"target": "esnext",
168
"lib": ["DOM", "DOM.Iterable", "ES2023"],
169
"resolveJsonModule": false,
170
"jsx": "react-jsx",
171
"declaration": true,
172
"newLine": "lf",
173
"stripInternal": true,
174
"erasableSyntaxOnly": true,
175
"strict": true,
176
"noImplicitReturns": true,
177
"noImplicitOverride": true,
178
"noUnusedLocals": true,
179
"noUnusedParameters": true,
180
"noFallthroughCasesInSwitch": true,
181
"noUncheckedIndexedAccess": true,
182
"noPropertyAccessFromIndexSignature": true,
183
"noUncheckedSideEffectImports": true,
184
"noEmitOnError": true,
185
"useDefineForClassFields": true,
186
"forceConsistentCasingInFileNames": true,
187
"skipLibCheck": true
188
}
189
}
190
```