@sicoti/tsconfig 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/LICENSE +21 -21
- package/README.md +381 -331
- package/base.json +90 -89
- package/bun.json +49 -39
- package/nestjs.json +55 -47
- package/nextjs.json +53 -47
- package/node.json +49 -0
- package/package.json +6 -6
- package/react-library.json +48 -42
package/README.md
CHANGED
|
@@ -1,331 +1,381 @@
|
|
|
1
|
-
# @sicoti/tsconfig
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
4
|
-
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
- 📦
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
###
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
##
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
###
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
"
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
##
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
1
|
+
# @sicoti/tsconfig
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
4
|
+
[](https://www.npmjs.com/package/@sicoti/tsconfig)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
> Centralized, shareable TypeScript configuration presets that enforce maximum type safety and best practices for modern JavaScript projects. Built for Next.js, NestJS, React libraries, and Bun with zero configuration.
|
|
9
|
+
|
|
10
|
+
## 📋 Table of Contents
|
|
11
|
+
|
|
12
|
+
- [🚀 Features](#-features)
|
|
13
|
+
- [📦 Installation](#-installation)
|
|
14
|
+
- [🔍 Requirements](#-requirements)
|
|
15
|
+
- [⚡ Quick Start](#-quick-start)
|
|
16
|
+
- [Next.js Applications](#nextjs-applications)
|
|
17
|
+
- [NestJS Applications](#nestjs-applications)
|
|
18
|
+
- [Bundled React Component Libraries](#bundled-react-component-libraries)
|
|
19
|
+
- [Bun Packages & CLI Tools](#bun-packages--cli-tools)
|
|
20
|
+
- [📋 Available Presets](#-available-presets)
|
|
21
|
+
- [🔒 Strict Type Checking](#-strict-type-checking)
|
|
22
|
+
- [Enabled by `strict: true`](#enabled-by-strict-true)
|
|
23
|
+
- [Additional Safety Checks (Not in `strict: true`)](#additional-safety-checks-not-in-strict-true)
|
|
24
|
+
- [❓ Why These Checks Matter](#-why-these-checks-matter)
|
|
25
|
+
- [`noUncheckedIndexedAccess`](#nouncheckedindexedaccess)
|
|
26
|
+
- [`noFallthroughCasesInSwitch`](#nofallthroughcasesinswitch)
|
|
27
|
+
- [`exactOptionalPropertyTypes`](#exactoptionalpropertytypes)
|
|
28
|
+
- [Why `strict: true` Alone Is Not Enough](#why-strict-true-alone-is-not-enough)
|
|
29
|
+
- [🏗️ Architecture](#️-architecture)
|
|
30
|
+
- [Design Philosophy](#design-philosophy)
|
|
31
|
+
- [🔧 Customization](#-customization)
|
|
32
|
+
- [📝 Changelog](#-changelog)
|
|
33
|
+
- [🤝 Contributing](#-contributing)
|
|
34
|
+
- [📄 License](#-license)
|
|
35
|
+
|
|
36
|
+
## ✨ Features
|
|
37
|
+
|
|
38
|
+
- 🔒 **Maximum Type Safety** — Strict mode plus additional safety checks beyond `strict: true`
|
|
39
|
+
- 📦 **Environment-Specific Presets** — Optimized configs for Next.js, NestJS, Node/shared libraries, React libraries, and Bun
|
|
40
|
+
- 🎯 **Zero Configuration** — Works out of the box with sensible defaults
|
|
41
|
+
- 🔧 **Fully Extensible** — Easy to override any setting for your specific needs
|
|
42
|
+
- 📚 **Well Documented** — Clear comments explaining every option
|
|
43
|
+
|
|
44
|
+
## 📦 Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# npm
|
|
48
|
+
npm install -D @sicoti/tsconfig typescript
|
|
49
|
+
|
|
50
|
+
# yarn
|
|
51
|
+
yarn add -D @sicoti/tsconfig typescript
|
|
52
|
+
|
|
53
|
+
# pnpm
|
|
54
|
+
pnpm add -D @sicoti/tsconfig typescript
|
|
55
|
+
|
|
56
|
+
# bun
|
|
57
|
+
bun add -D @sicoti/tsconfig typescript
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🔍 Requirements
|
|
61
|
+
|
|
62
|
+
- **TypeScript**: `>= 6 < 8` (consumer fixtures are compiled with TypeScript 6 and TypeScript 7)
|
|
63
|
+
- **Node.js**: `>= 24.0.0`
|
|
64
|
+
- **Package Manager**: npm, yarn, pnpm, or bun
|
|
65
|
+
|
|
66
|
+
## ⚡ Quick Start
|
|
67
|
+
|
|
68
|
+
Choose the preset that matches your project type and extend it in your `tsconfig.json`:
|
|
69
|
+
|
|
70
|
+
### Next.js Applications
|
|
71
|
+
|
|
72
|
+
```jsonc
|
|
73
|
+
{
|
|
74
|
+
"extends": "@sicoti/tsconfig/nextjs.json",
|
|
75
|
+
"compilerOptions": {
|
|
76
|
+
"paths": {
|
|
77
|
+
"@/*": ["./src/*"]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
81
|
+
"exclude": ["node_modules"]
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### NestJS Applications
|
|
86
|
+
|
|
87
|
+
```jsonc
|
|
88
|
+
{
|
|
89
|
+
"extends": "@sicoti/tsconfig/nestjs.json",
|
|
90
|
+
"compilerOptions": {
|
|
91
|
+
"outDir": "./dist",
|
|
92
|
+
"paths": {
|
|
93
|
+
"@/*": ["./src/*"]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"include": ["src/**/*"],
|
|
97
|
+
"exclude": ["node_modules", "dist"]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Bundled React Component Libraries
|
|
102
|
+
|
|
103
|
+
`react-library.json` models source that is bundled before publication (for
|
|
104
|
+
example with tsdown, Rolldown, Vite library mode, or an equivalent build tool).
|
|
105
|
+
TypeScript typechecks the source while the bundler owns JavaScript and declaration
|
|
106
|
+
output.
|
|
107
|
+
|
|
108
|
+
```jsonc
|
|
109
|
+
{
|
|
110
|
+
"extends": "@sicoti/tsconfig/react-library.json",
|
|
111
|
+
"compilerOptions": {
|
|
112
|
+
"paths": {
|
|
113
|
+
"@/*": ["./src/*"]
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"include": ["src/**/*"],
|
|
117
|
+
"exclude": ["dist", "node_modules"]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Bun Packages & CLI Tools
|
|
122
|
+
|
|
123
|
+
```jsonc
|
|
124
|
+
{
|
|
125
|
+
"extends": "@sicoti/tsconfig/bun.json",
|
|
126
|
+
"compilerOptions": {
|
|
127
|
+
"paths": {
|
|
128
|
+
"@/*": ["./src/*"]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"include": ["src/**/*"],
|
|
132
|
+
"exclude": ["dist", "node_modules"]
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Node / Shared Libraries
|
|
137
|
+
|
|
138
|
+
`node.json` models direct Node ESM execution with `NodeNext` resolution and
|
|
139
|
+
declaration emit. Relative ESM imports therefore use the runtime extension that
|
|
140
|
+
Node will execute (for example `./value.js` from TypeScript source):
|
|
141
|
+
|
|
142
|
+
```jsonc
|
|
143
|
+
{
|
|
144
|
+
"extends": "@sicoti/tsconfig/node.json",
|
|
145
|
+
"include": ["src/**/*"]
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 📋 Available Presets
|
|
150
|
+
|
|
151
|
+
| Preset | Use Case | Key Features |
|
|
152
|
+
| :------- | :--------- | :------------- |
|
|
153
|
+
| `nextjs.json` | Next.js apps (App Router / Pages Router) | `jsx: preserve`, `noEmit`, Next.js plugin |
|
|
154
|
+
| `nestjs.json` | NestJS backend applications executed by Node | `NodeNext`, decorator metadata, source maps, DI support |
|
|
155
|
+
| `node.json` | Node ESM packages/libraries that emit declarations | `NodeNext`, Node types, declaration + source-map emit |
|
|
156
|
+
| `react-library.json` | React libraries bundled before publication | `module: Preserve`, bundler resolution, `jsx: react-jsx`, `noEmit` |
|
|
157
|
+
| `bun.json` | Bun-native packages & CLI tools | `module: Preserve`, bundler resolution, `.ts` imports, `noEmit` |
|
|
158
|
+
| `base.json` | ⚠️ Internal foundation (not for direct use) | Universal strict settings |
|
|
159
|
+
|
|
160
|
+
## 🔒 Strict Type Checking
|
|
161
|
+
|
|
162
|
+
All presets inherit from `base.json` which enables maximum type safety:
|
|
163
|
+
|
|
164
|
+
### Enabled by `strict: true`
|
|
165
|
+
|
|
166
|
+
| Option | Description |
|
|
167
|
+
| :------- | :------------ |
|
|
168
|
+
| `strictNullChecks` | Check null/undefined assignments |
|
|
169
|
+
| `strictFunctionTypes` | Strict function type checking |
|
|
170
|
+
| `strictBindCallApply` | Type checking for bind/call/apply |
|
|
171
|
+
| `strictPropertyInitialization` | Ensure class properties are initialized |
|
|
172
|
+
| `noImplicitThis` | Error on implicit 'this' types |
|
|
173
|
+
| `noImplicitAny` | Error on implicit 'any' types |
|
|
174
|
+
| `alwaysStrict` | Emit "use strict" in all files |
|
|
175
|
+
| `useUnknownInCatchVariables` | Use 'unknown' instead of 'any' in catch |
|
|
176
|
+
|
|
177
|
+
### Additional Safety Checks (Not in `strict: true`)
|
|
178
|
+
|
|
179
|
+
| Option | Description |
|
|
180
|
+
| :------- | :------------ |
|
|
181
|
+
| `noUnusedLocals` | Error on unused local variables |
|
|
182
|
+
| `noUnusedParameters` | Error on unused function parameters |
|
|
183
|
+
| `noImplicitReturns` | Error when not all paths return a value |
|
|
184
|
+
| `noFallthroughCasesInSwitch` | Error on switch case fall-through |
|
|
185
|
+
| `allowUnreachableCode` | Error on unreachable code |
|
|
186
|
+
| `noUncheckedIndexedAccess` | Add `undefined` to index signature results |
|
|
187
|
+
| `noPropertyAccessFromIndexSignature` | Require bracket notation for index access |
|
|
188
|
+
| `noImplicitOverride` | Require 'override' keyword for overrides |
|
|
189
|
+
| `noUncheckedSideEffectImports` | Validate side-effect imports exist |
|
|
190
|
+
|
|
191
|
+
`exactOptionalPropertyTypes` is deliberately `false` in the shared baseline for
|
|
192
|
+
the current NestJS/Prisma/React compatibility boundary. This does not relax
|
|
193
|
+
`strict`, `noUncheckedIndexedAccess`, or `noPropertyAccessFromIndexSignature`.
|
|
194
|
+
|
|
195
|
+
## 💡 Why These Checks Matter
|
|
196
|
+
|
|
197
|
+
### `noUncheckedIndexedAccess`
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// ❌ Without: No error, crashes at runtime
|
|
201
|
+
const users: User[] = [];
|
|
202
|
+
const first = users[0]; // Type: User (WRONG!)
|
|
203
|
+
first.name; // 💥 Runtime error: Cannot read property 'name' of undefined
|
|
204
|
+
|
|
205
|
+
// ✅ With: Compiler catches it
|
|
206
|
+
const first = users[0]; // Type: User | undefined
|
|
207
|
+
if (first) {
|
|
208
|
+
first.name; // ✓ Safe access
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### `noFallthroughCasesInSwitch`
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// ❌ Without: Silent fall-through bug
|
|
216
|
+
switch (action) {
|
|
217
|
+
case "login":
|
|
218
|
+
login();
|
|
219
|
+
// Oops! Falls through to logout!
|
|
220
|
+
case "logout":
|
|
221
|
+
logout();
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ✅ With: TS7029 error prevents the bug
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `exactOptionalPropertyTypes`
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
interface Config {
|
|
232
|
+
cache?: { ttl: number };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ❌ Without: Both accepted but have different semantics
|
|
236
|
+
setConfig({}); // OK - cache is missing
|
|
237
|
+
setConfig({ cache: undefined }); // OK - but this explicitly sets cache to undefined!
|
|
238
|
+
|
|
239
|
+
// ✅ With: Explicit undefined is an error
|
|
240
|
+
// TS2379: Type 'undefined' is not assignable to type '{ ttl: number }'
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Why `strict: true` Alone Is Not Enough
|
|
244
|
+
|
|
245
|
+
Many developers assume that `"strict": true` enables all TypeScript safety checks. **This is a common misconception.** The `strict` flag only enables 8 specific checks, leaving many critical safety features disabled by default.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
// ❌ This code compiles with ONLY strict: true
|
|
249
|
+
|
|
250
|
+
// 1. Unused variables? No error.
|
|
251
|
+
const unusedVar = "I'm never used";
|
|
252
|
+
|
|
253
|
+
// 2. Array access without bounds checking? No error.
|
|
254
|
+
const users: string[] = [];
|
|
255
|
+
const first = users[0]; // Type: string (but it's actually undefined!)
|
|
256
|
+
first.toUpperCase(); // 💥 Runtime crash!
|
|
257
|
+
|
|
258
|
+
// 3. Switch fall-through? No error.
|
|
259
|
+
function handle(action: "save" | "delete") {
|
|
260
|
+
switch (action) {
|
|
261
|
+
case "save":
|
|
262
|
+
save();
|
|
263
|
+
// Oops! Falls through to delete!
|
|
264
|
+
case "delete":
|
|
265
|
+
deleteAll(); // 💥 Unintended deletion!
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// 4. Missing return in some branches? No error.
|
|
270
|
+
function getValue(condition: boolean): string {
|
|
271
|
+
if (condition) {
|
|
272
|
+
return "value";
|
|
273
|
+
}
|
|
274
|
+
// 💥 Returns undefined, but TypeScript says it returns string!
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
// ✅ With @sicoti/tsconfig - ALL of these are caught at compile time!
|
|
280
|
+
|
|
281
|
+
// 1. TS6133: 'unusedVar' is declared but never used
|
|
282
|
+
const unusedVar = "I'm never used";
|
|
283
|
+
|
|
284
|
+
// 2. TS18048: 'first' is possibly 'undefined'
|
|
285
|
+
const users: string[] = [];
|
|
286
|
+
const first = users[0]; // Type: string | undefined
|
|
287
|
+
if (first) {
|
|
288
|
+
first.toUpperCase(); // ✓ Safe!
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 3. TS7029: Fallthrough case in switch
|
|
292
|
+
function handle(action: "save" | "delete") {
|
|
293
|
+
switch (action) {
|
|
294
|
+
case "save":
|
|
295
|
+
save();
|
|
296
|
+
break; // ✓ Required!
|
|
297
|
+
case "delete":
|
|
298
|
+
deleteAll();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 4. TS7030: Not all code paths return a value
|
|
303
|
+
function getValue(condition: boolean): string {
|
|
304
|
+
if (condition) {
|
|
305
|
+
return "value";
|
|
306
|
+
}
|
|
307
|
+
return "default"; // ✓ Required!
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Bottom line:** `strict: true` is just the starting point. This package enables **10+ additional checks** that catch real bugs before they reach production.
|
|
312
|
+
|
|
313
|
+
## 🏗️ Architecture
|
|
314
|
+
|
|
315
|
+
```mermaid
|
|
316
|
+
flowchart TD
|
|
317
|
+
base["base.json<br/>Foundation (DO NOT extend directly)<br/>Universal strict settings"] --> nextjs["nextjs.json<br/>Next.js applications<br/>jsx: preserve, noEmit, Next.js plugin"]
|
|
318
|
+
base --> nestjs["nestjs.json<br/>NestJS on Node<br/>NodeNext, decorators, source maps"]
|
|
319
|
+
base --> node["node.json<br/>Direct Node ESM<br/>NodeNext, declaration emit"]
|
|
320
|
+
base --> bun["bun.json<br/>Bun-native runtime<br/>Preserve, bundler resolution, noEmit"]
|
|
321
|
+
base --> reactlib["react-library.json<br/>Bundled React libraries<br/>Preserve, bundler resolution, noEmit"]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Design Philosophy
|
|
325
|
+
|
|
326
|
+
**`base.json` includes:**
|
|
327
|
+
|
|
328
|
+
- Universal strict type checking settings
|
|
329
|
+
- Runtime-neutral module hygiene
|
|
330
|
+
- Code quality checks (unused code, control flow)
|
|
331
|
+
- Import safety validations
|
|
332
|
+
|
|
333
|
+
**`base.json` intentionally excludes:**
|
|
334
|
+
|
|
335
|
+
- `lib` (DOM, ESNext) — Varies by runtime environment
|
|
336
|
+
- `target`, `module`, `moduleResolution` — Must model the actual runtime/bundler
|
|
337
|
+
- `jsx` settings — Only for React-based projects
|
|
338
|
+
- `sourceMap`, `declaration` — Build output varies by project
|
|
339
|
+
- `emitDecoratorMetadata` — Only for NestJS/decorator-based DI
|
|
340
|
+
|
|
341
|
+
## 🔧 Customization
|
|
342
|
+
|
|
343
|
+
You can override any setting in your project's `tsconfig.json`:
|
|
344
|
+
|
|
345
|
+
```jsonc
|
|
346
|
+
{
|
|
347
|
+
"extends": "@sicoti/tsconfig/nextjs.json",
|
|
348
|
+
"compilerOptions": {
|
|
349
|
+
// Override specific settings
|
|
350
|
+
"noUncheckedIndexedAccess": false, // Disable if too strict for your codebase
|
|
351
|
+
"paths": {
|
|
352
|
+
"@/*": ["./src/*"],
|
|
353
|
+
"@components/*": ["./src/components/*"]
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## 📝 Changelog
|
|
360
|
+
|
|
361
|
+
See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.
|
|
362
|
+
|
|
363
|
+
## 🤝 Contributing
|
|
364
|
+
|
|
365
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
366
|
+
|
|
367
|
+
1. Fork the repository
|
|
368
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
369
|
+
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
370
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
371
|
+
5. Open a Pull Request
|
|
372
|
+
|
|
373
|
+
## 📄 License
|
|
374
|
+
|
|
375
|
+
[MIT](LICENSE) © [SICOTI Team](https://github.com/SICOTI-Peru)
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
<p align="center">
|
|
380
|
+
Made with ❤️ by the <a href="https://github.com/SICOTI-Peru">SICOTI Team</a>
|
|
381
|
+
</p>
|