@jmlweb/tsconfig-base 1.0.3 → 1.0.4
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 +6 -0
- package/README.md +39 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
## 📦 Installation
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
21
|
+
pnpm add -D @jmlweb/tsconfig-base typescript
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
@@ -159,6 +159,44 @@ This base config intentionally omits `include` and `exclude` patterns because:
|
|
|
159
159
|
- ✅ Prevents conflicts with project-specific patterns
|
|
160
160
|
- ✅ More flexible for various project types
|
|
161
161
|
|
|
162
|
+
## 🤔 Why Use This?
|
|
163
|
+
|
|
164
|
+
> **Philosophy**: TypeScript should catch bugs at compile time through strict type checking. If it compiles without errors, it should work correctly.
|
|
165
|
+
|
|
166
|
+
This package provides an opinionated TypeScript configuration that enables all strict flags and additional safety checks. It's designed to prevent common JavaScript pitfalls through TypeScript's type system while remaining flexible enough for any project type.
|
|
167
|
+
|
|
168
|
+
### Design Decisions
|
|
169
|
+
|
|
170
|
+
**All Strict Flags Enabled (`strict: true` + extras)**: Enables strict null checks, no implicit any, strict function types, etc.
|
|
171
|
+
|
|
172
|
+
- **Why**: TypeScript's strict mode catches entire classes of bugs (null/undefined errors, implicit any holes, binding issues). Additional flags like `noUncheckedIndexedAccess` catch even more edge cases
|
|
173
|
+
- **Trade-off**: More initial type errors when adopting, requires explicit null handling. But this prevents runtime crashes
|
|
174
|
+
- **When to override**: For gradual migration from JavaScript (but aim to enable all flags eventually)
|
|
175
|
+
|
|
176
|
+
**Modern Target (ES2022)**: Compiles to ES2022 with modern JavaScript features
|
|
177
|
+
|
|
178
|
+
- **Why**: Modern Node.js and browsers support ES2022. Using modern features provides better performance and cleaner output. Let your runtime handle the code
|
|
179
|
+
- **Trade-off**: Requires Node.js 18+ or modern browsers. If targeting older environments, override with `ES2020` or lower
|
|
180
|
+
- **When to override**: When supporting legacy environments (but consider transpiling separately)
|
|
181
|
+
|
|
182
|
+
**NodeNext Module Resolution**: Uses Node.js ESM resolution algorithm
|
|
183
|
+
|
|
184
|
+
- **Why**: Matches how Node.js resolves modules in real projects. Prevents module resolution mismatches between TypeScript and runtime
|
|
185
|
+
- **Trade-off**: Requires proper package.json exports and file extensions in imports. But this matches modern JavaScript standards
|
|
186
|
+
- **When to override**: For legacy projects using CommonJS exclusively (but you should migrate to ESM)
|
|
187
|
+
|
|
188
|
+
**No File Inclusion**: Doesn't specify `include` or `exclude` patterns
|
|
189
|
+
|
|
190
|
+
- **Why**: Different projects have different structures (src/, lib/, packages/). Config shouldn't impose opinions about project layout
|
|
191
|
+
- **Trade-off**: Must define your own `include`/`exclude` in project tsconfig.json (but you'd do this anyway for custom needs)
|
|
192
|
+
- **When to override**: Never - add include/exclude in your project's tsconfig.json
|
|
193
|
+
|
|
194
|
+
**Source Maps Enabled**: Generates source maps for debugging
|
|
195
|
+
|
|
196
|
+
- **Why**: Source maps enable debugging TypeScript source in Node.js and browsers. Essential for production debugging
|
|
197
|
+
- **Trade-off**: Slightly larger build output, but negligible compared to debugging benefits
|
|
198
|
+
- **When to override**: If you're absolutely certain you don't need debugging (rare)
|
|
199
|
+
|
|
162
200
|
## 🎯 When to Use
|
|
163
201
|
|
|
164
202
|
Use this configuration when you want:
|