@jmlweb/tsconfig-base 1.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.
Files changed (3) hide show
  1. package/README.md +210 -0
  2. package/package.json +36 -0
  3. package/tsconfig.json +24 -0
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # @jmlweb/tsconfig-base
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@jmlweb/tsconfig-base)](https://www.npmjs.com/package/@jmlweb/tsconfig-base)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-339933.svg)](https://nodejs.org/)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-3178C6.svg)](https://www.typescriptlang.org/)
7
+
8
+ > Base TypeScript configuration with strict type checking and modern defaults. Designed to be extended by projects without imposing file inclusion/exclusion patterns.
9
+
10
+ ## ✨ Features
11
+
12
+ - πŸ”’ **Strict Mode**: All strict flags enabled for maximum type safety
13
+ - πŸš€ **Modern Defaults**: ES2022 target with NodeNext module resolution
14
+ - πŸ›‘οΈ **Extra Safety**: Additional strict checks beyond the `strict` flag
15
+ - 🎯 **Flexible**: No `include`/`exclude` defined - you control what gets compiled
16
+ - πŸ—ΊοΈ **Source Maps**: Enabled by default for debugging
17
+
18
+ ## πŸ“¦ Installation
19
+
20
+ ```bash
21
+ npm install --save-dev @jmlweb/tsconfig-base typescript
22
+ ```
23
+
24
+ ## πŸš€ Quick Start
25
+
26
+ Create a `tsconfig.json` file in your project root:
27
+
28
+ ```json
29
+ {
30
+ "extends": "@jmlweb/tsconfig-base",
31
+ "compilerOptions": {
32
+ "outDir": "./dist",
33
+ "rootDir": "./src"
34
+ },
35
+ "include": ["src/**/*"],
36
+ "exclude": ["node_modules", "dist"]
37
+ }
38
+ ```
39
+
40
+ ## πŸ’‘ Examples
41
+
42
+ ### Node.js Project
43
+
44
+ ```json
45
+ {
46
+ "extends": "@jmlweb/tsconfig-base",
47
+ "compilerOptions": {
48
+ "outDir": "./dist",
49
+ "rootDir": "./src"
50
+ },
51
+ "include": ["src/**/*"],
52
+ "exclude": ["node_modules", "dist"]
53
+ }
54
+ ```
55
+
56
+ ### Library with Multiple Entry Points
57
+
58
+ ```json
59
+ {
60
+ "extends": "@jmlweb/tsconfig-base",
61
+ "compilerOptions": {
62
+ "outDir": "./dist",
63
+ "rootDir": "./src",
64
+ "composite": true
65
+ },
66
+ "include": ["src/**/*"],
67
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
68
+ }
69
+ ```
70
+
71
+ ### Monorepo Package
72
+
73
+ ```json
74
+ {
75
+ "extends": "@jmlweb/tsconfig-base",
76
+ "compilerOptions": {
77
+ "outDir": "./dist",
78
+ "rootDir": "./src",
79
+ "composite": true,
80
+ "declarationDir": "./dist"
81
+ },
82
+ "include": ["src/**/*"],
83
+ "exclude": ["node_modules", "dist"]
84
+ }
85
+ ```
86
+
87
+ ### React Project
88
+
89
+ ```json
90
+ {
91
+ "extends": "@jmlweb/tsconfig-base",
92
+ "compilerOptions": {
93
+ "outDir": "./dist",
94
+ "rootDir": "./src",
95
+ "jsx": "react-jsx"
96
+ },
97
+ "include": ["src/**/*"],
98
+ "exclude": ["node_modules", "dist"]
99
+ }
100
+ ```
101
+
102
+ ### Overriding Options
103
+
104
+ You can override any option in your project's `tsconfig.json`:
105
+
106
+ ```json
107
+ {
108
+ "extends": "@jmlweb/tsconfig-base",
109
+ "compilerOptions": {
110
+ "target": "ES2020",
111
+ "noUncheckedIndexedAccess": false
112
+ },
113
+ "include": ["src/**/*"]
114
+ }
115
+ ```
116
+
117
+ ## πŸ“‹ Configuration Details
118
+
119
+ ### Compiler Options Included
120
+
121
+ | Option | Value | Description |
122
+ | ------------------------------------ | ---------- | ---------------------------------------------- |
123
+ | `strict` | `true` | Enables all strict type checking options |
124
+ | `target` | `ES2022` | Modern JavaScript features |
125
+ | `module` | `NodeNext` | Node.js ESM module system |
126
+ | `moduleResolution` | `NodeNext` | Node.js module resolution |
127
+ | `esModuleInterop` | `true` | CommonJS/ESM interoperability |
128
+ | `skipLibCheck` | `true` | Skip type checking of declaration files |
129
+ | `forceConsistentCasingInFileNames` | `true` | Enforce consistent file name casing |
130
+ | `declaration` | `true` | Generate `.d.ts` files |
131
+ | `declarationMap` | `true` | Generate sourcemaps for `.d.ts` files |
132
+ | `sourceMap` | `true` | Generate sourcemaps for debugging |
133
+ | `noUncheckedIndexedAccess` | `true` | Add `undefined` to index signatures |
134
+ | `noImplicitOverride` | `true` | Require `override` keyword |
135
+ | `noPropertyAccessFromIndexSignature` | `true` | Require bracket notation for index signatures |
136
+ | `exactOptionalPropertyTypes` | `true` | Differentiate between `undefined` and optional |
137
+ | `noFallthroughCasesInSwitch` | `true` | Report fallthrough cases in switch |
138
+ | `isolatedModules` | `true` | Ensure compatibility with transpilers |
139
+ | `verbatimModuleSyntax` | `true` | Enforce explicit type imports/exports |
140
+ | `resolveJsonModule` | `true` | Allow importing JSON files |
141
+
142
+ ### What You Need to Configure
143
+
144
+ Since this base config intentionally omits file patterns, you must configure:
145
+
146
+ - βœ… `include`: Which files to compile (e.g., `["src/**/*"]`)
147
+ - βœ… `exclude`: Which files to ignore (e.g., `["node_modules", "dist"]`)
148
+ - βœ… `outDir`: Output directory for compiled files
149
+ - βœ… `rootDir`: Root directory of source files (optional but recommended)
150
+
151
+ ## 🎯 Why No File Patterns?
152
+
153
+ This base config intentionally omits `include` and `exclude` patterns because:
154
+
155
+ - βœ… Different projects have different file structures
156
+ - βœ… You maintain full control over what gets compiled
157
+ - βœ… Prevents conflicts with project-specific patterns
158
+ - βœ… More flexible for various project types
159
+
160
+ ## πŸ”§ Common Overrides
161
+
162
+ ### Using ES Modules (ESM)
163
+
164
+ ```json
165
+ {
166
+ "extends": "@jmlweb/tsconfig-base",
167
+ "compilerOptions": {
168
+ "module": "ESNext",
169
+ "moduleResolution": "bundler"
170
+ }
171
+ }
172
+ ```
173
+
174
+ ### Using CommonJS
175
+
176
+ ```json
177
+ {
178
+ "extends": "@jmlweb/tsconfig-base",
179
+ "compilerOptions": {
180
+ "module": "CommonJS",
181
+ "moduleResolution": "node"
182
+ }
183
+ }
184
+ ```
185
+
186
+ ### Less Strict Configuration
187
+
188
+ ```json
189
+ {
190
+ "extends": "@jmlweb/tsconfig-base",
191
+ "compilerOptions": {
192
+ "noUncheckedIndexedAccess": false,
193
+ "exactOptionalPropertyTypes": false
194
+ }
195
+ }
196
+ ```
197
+
198
+ ## πŸ“ Requirements
199
+
200
+ - **Node.js** >= 18.0.0
201
+ - **TypeScript** >= 5.0.0
202
+
203
+ ## πŸ”— Related Packages
204
+
205
+ - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint configuration for TypeScript projects
206
+ - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier configuration
207
+
208
+ ## πŸ“„ License
209
+
210
+ MIT
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@jmlweb/tsconfig-base",
3
+ "version": "1.0.0",
4
+ "description": "Base TypeScript configuration with strict type checking and modern defaults",
5
+ "main": "tsconfig.json",
6
+ "exports": {
7
+ ".": "./tsconfig.json"
8
+ },
9
+ "files": [
10
+ "tsconfig.json",
11
+ "README.md"
12
+ ],
13
+ "keywords": [
14
+ "tsconfig",
15
+ "typescript",
16
+ "config",
17
+ "strict",
18
+ "type-checking"
19
+ ],
20
+ "author": "jmlweb",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/jmlweb/tooling.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/jmlweb/tooling/issues"
28
+ },
29
+ "homepage": "https://github.com/jmlweb/tooling/tree/main/packages/tsconfig-base#readme",
30
+ "engines": {
31
+ "node": ">=18.0.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "@jmlweb/tsconfig-base",
4
+ "compilerOptions": {
5
+ "strict": true,
6
+ "target": "ES2022",
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext",
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "noUncheckedIndexedAccess": true,
16
+ "noImplicitOverride": true,
17
+ "noPropertyAccessFromIndexSignature": true,
18
+ "exactOptionalPropertyTypes": true,
19
+ "noFallthroughCasesInSwitch": true,
20
+ "isolatedModules": true,
21
+ "verbatimModuleSyntax": true,
22
+ "resolveJsonModule": true
23
+ }
24
+ }