@dimensional-innovations/tool-config 4.0.0 → 5.0.1
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/LICENSE +1 -1
- package/README.md +7 -120
- package/dist/cli/index.js +1812 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +401 -0
- package/dist/index.js +2644 -0
- package/dist/index.js.map +1 -0
- package/package.json +22 -15
- package/bin/lib/ci-setup.js +0 -142
- package/bin/lib/formatting.js +0 -103
- package/bin/lib/handlers/eslint.js +0 -61
- package/bin/lib/handlers/prettier.js +0 -83
- package/bin/lib/handlers/semantic-release.js +0 -60
- package/bin/lib/handlers/stylelint.js +0 -85
- package/bin/lib/handlers/typescript.js +0 -156
- package/bin/lib/package-manager.js +0 -201
- package/bin/lib/ui.js +0 -239
- package/bin/lib/uninstall.js +0 -199
- package/bin/lib/validators.js +0 -28
- package/bin/setup-tool-config.js +0 -442
- package/src/detectors.js +0 -286
- package/src/index.js +0 -69
- package/src/tools/eslint/index.js +0 -282
- package/src/tools/eslint/presets/base.js +0 -75
- package/src/tools/eslint/presets/environments/browser.js +0 -16
- package/src/tools/eslint/presets/environments/node.js +0 -21
- package/src/tools/eslint/presets/environments/universal.js +0 -18
- package/src/tools/eslint/presets/frameworks/angular.js +0 -80
- package/src/tools/eslint/presets/frameworks/astro.js +0 -43
- package/src/tools/eslint/presets/frameworks/node.js +0 -63
- package/src/tools/eslint/presets/frameworks/react.js +0 -81
- package/src/tools/eslint/presets/frameworks/solid.js +0 -50
- package/src/tools/eslint/presets/frameworks/svelte.js +0 -65
- package/src/tools/eslint/presets/frameworks/vanilla.js +0 -22
- package/src/tools/eslint/presets/frameworks/vue.js +0 -159
- package/src/tools/eslint/presets/imports.js +0 -47
- package/src/tools/eslint/presets/typescript.js +0 -142
- package/src/tools/prettier/README.md +0 -398
- package/src/tools/prettier/index.js +0 -132
- package/src/tools/prettier/presets/base.js +0 -36
- package/src/tools/prettier/presets/frameworks/astro.js +0 -15
- package/src/tools/prettier/presets/frameworks/react.js +0 -15
- package/src/tools/prettier/presets/frameworks/svelte.js +0 -22
- package/src/tools/prettier/presets/frameworks/vanilla.js +0 -13
- package/src/tools/prettier/presets/frameworks/vue.js +0 -21
- package/src/tools/prettier/presets/prettierignore.js +0 -57
- package/src/tools/semantic-release/CI_SETUP.md +0 -66
- package/src/tools/semantic-release/README.md +0 -533
- package/src/tools/semantic-release/index.js +0 -130
- package/src/tools/semantic-release/presets/default.js +0 -37
- package/src/tools/semantic-release/presets/library.js +0 -58
- package/src/tools/semantic-release/presets/monorepo.js +0 -48
- package/src/tools/semantic-release/templates/.gitlab-ci.yml +0 -89
- package/src/tools/semantic-release/templates/bitbucket-pipelines.yml +0 -100
- package/src/tools/semantic-release/templates/github-workflow.yml +0 -107
- package/src/tools/stylelint/README.md +0 -425
- package/src/tools/stylelint/index.js +0 -195
- package/src/tools/stylelint/presets/base.js +0 -50
- package/src/tools/stylelint/presets/css-modules.js +0 -43
- package/src/tools/stylelint/presets/frameworks/react.js +0 -18
- package/src/tools/stylelint/presets/frameworks/svelte.js +0 -28
- package/src/tools/stylelint/presets/frameworks/vanilla.js +0 -14
- package/src/tools/stylelint/presets/frameworks/vue.js +0 -38
- package/src/tools/stylelint/presets/scss.js +0 -83
- package/src/tools/stylelint/presets/tailwind.js +0 -49
- package/src/tools/typescript/README.md +0 -665
- package/src/tools/typescript/checker-detection.js +0 -113
- package/src/tools/typescript/index.js +0 -202
- package/src/tools/typescript/presets/base.js +0 -58
- package/src/tools/typescript/presets/environments/browser.js +0 -10
- package/src/tools/typescript/presets/environments/node.js +0 -11
- package/src/tools/typescript/presets/environments/universal.js +0 -11
- package/src/tools/typescript/presets/frameworks/angular.js +0 -11
- package/src/tools/typescript/presets/frameworks/astro.js +0 -11
- package/src/tools/typescript/presets/frameworks/electron.js +0 -100
- package/src/tools/typescript/presets/frameworks/node.js +0 -12
- package/src/tools/typescript/presets/frameworks/react.js +0 -10
- package/src/tools/typescript/presets/frameworks/solid.js +0 -11
- package/src/tools/typescript/presets/frameworks/svelte.js +0 -10
- package/src/tools/typescript/presets/frameworks/vanilla.js +0 -9
- package/src/tools/typescript/presets/frameworks/vue.js +0 -17
- package/src/utils/ignore-patterns.js +0 -157
- package/src/utils/package-reader.js +0 -42
|
@@ -1,665 +0,0 @@
|
|
|
1
|
-
# TypeScript Configuration
|
|
2
|
-
|
|
3
|
-
Zero-config TypeScript type checking for modern JavaScript/TypeScript projects.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Auto-detection** of framework, environment, and TypeScript setup
|
|
8
|
-
- **Modern tooling** with tsgo (10x faster than tsc)
|
|
9
|
-
- **Framework-specific** configurations for React, Vue, Svelte, Solid, Astro, Angular, Vanilla, and Node.js
|
|
10
|
-
- **Strict mode** enabled by default with opt-out
|
|
11
|
-
- **Smart checker selection** - tsgo → vue-tsc → tsc fallback chain
|
|
12
|
-
- **Zero config** - works out of the box with sensible defaults
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
yarn add --save-dev @dimensional-innovations/tool-config typescript
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
For modern performance with tsgo:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
yarn add --save-dev @typescript/native-preview
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
For Vue projects, also install:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
yarn add --save-dev vue-tsc
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Quick Start
|
|
33
|
-
|
|
34
|
-
Create `tsconfig.json` in your project root:
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{
|
|
38
|
-
"extends": "./tsconfig.base.json",
|
|
39
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
40
|
-
"include": ["src/**/*"],
|
|
41
|
-
"exclude": ["node_modules", "dist"]
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Create `tsconfig.base.json` using the package:
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
// tsconfig.base.json
|
|
49
|
-
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
50
|
-
|
|
51
|
-
export default await createConfig('typescript', { framework: 'auto' })
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Add type checking script to `package.json`:
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"scripts": {
|
|
59
|
-
"typecheck": "tsc --noEmit",
|
|
60
|
-
"typecheck:watch": "tsc --noEmit --watch"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
If you have tsgo installed, the package will auto-generate the appropriate command.
|
|
66
|
-
|
|
67
|
-
## Configuration Options
|
|
68
|
-
|
|
69
|
-
### Basic Options
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
createConfig('typescript', {
|
|
73
|
-
framework: 'auto', // 'auto', 'react', 'vue', 'svelte', 'solid', 'astro', 'angular', 'vanilla', 'node'
|
|
74
|
-
environment: 'auto', // 'auto', 'browser', 'node', 'universal'
|
|
75
|
-
checker: 'auto', // 'auto', 'modern' (tsgo), 'legacy' (tsc/vue-tsc)
|
|
76
|
-
strict: true, // Enable strict type checking
|
|
77
|
-
cwd: process.cwd() // Working directory for detection
|
|
78
|
-
})
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Compiler Options Override
|
|
82
|
-
|
|
83
|
-
```javascript
|
|
84
|
-
createConfig('typescript', {
|
|
85
|
-
framework: 'react',
|
|
86
|
-
compilerOptions: {
|
|
87
|
-
target: 'ES2020',
|
|
88
|
-
outDir: './dist',
|
|
89
|
-
rootDir: './src',
|
|
90
|
-
baseUrl: '.',
|
|
91
|
-
paths: {
|
|
92
|
-
'@/*': ['src/*']
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Framework-Specific Setup
|
|
99
|
-
|
|
100
|
-
### React
|
|
101
|
-
|
|
102
|
-
Auto-detected from `react` in dependencies.
|
|
103
|
-
|
|
104
|
-
**Default configuration:**
|
|
105
|
-
|
|
106
|
-
- JSX: `react-jsx` (modern React 17+ runtime)
|
|
107
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
108
|
-
- Target: ES2020
|
|
109
|
-
|
|
110
|
-
**Example tsconfig.base.json:**
|
|
111
|
-
|
|
112
|
-
```javascript
|
|
113
|
-
export default await createConfig('typescript', { framework: 'react' })
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**Type checking:**
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
yarn add --save-dev @types/react @types/react-dom
|
|
120
|
-
yarn typecheck
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Vue
|
|
124
|
-
|
|
125
|
-
Auto-detected from `vue`, `vue-router`, or `pinia` in dependencies.
|
|
126
|
-
|
|
127
|
-
**Default configuration:**
|
|
128
|
-
|
|
129
|
-
- JSX: `preserve` (Vue compiler handles it)
|
|
130
|
-
- JSX Import Source: `vue`
|
|
131
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
132
|
-
- Types: `vite/client`
|
|
133
|
-
- Vue compiler options included
|
|
134
|
-
|
|
135
|
-
**Example tsconfig.base.json:**
|
|
136
|
-
|
|
137
|
-
```javascript
|
|
138
|
-
export default await createConfig('typescript', { framework: 'vue' })
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Type checking:**
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
yarn add --save-dev vue-tsc
|
|
145
|
-
yarn typecheck
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
**Note:** Vue projects should use `vue-tsc` instead of `tsc` for proper .vue file support.
|
|
149
|
-
|
|
150
|
-
### Svelte
|
|
151
|
-
|
|
152
|
-
Auto-detected from `svelte` in dependencies.
|
|
153
|
-
|
|
154
|
-
**Default configuration:**
|
|
155
|
-
|
|
156
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
157
|
-
- Types: `svelte`
|
|
158
|
-
|
|
159
|
-
**Example tsconfig.base.json:**
|
|
160
|
-
|
|
161
|
-
```javascript
|
|
162
|
-
export default await createConfig('typescript', { framework: 'svelte' })
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**Type checking:**
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
yarn add --save-dev @sveltejs/vite-plugin-svelte
|
|
169
|
-
yarn typecheck
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Solid
|
|
173
|
-
|
|
174
|
-
Auto-detected from `solid-js` in dependencies.
|
|
175
|
-
|
|
176
|
-
**Default configuration:**
|
|
177
|
-
|
|
178
|
-
- JSX: `preserve`
|
|
179
|
-
- JSX Import Source: `solid-js`
|
|
180
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
181
|
-
|
|
182
|
-
**Example tsconfig.base.json:**
|
|
183
|
-
|
|
184
|
-
```javascript
|
|
185
|
-
export default await createConfig('typescript', { framework: 'solid' })
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Astro
|
|
189
|
-
|
|
190
|
-
Auto-detected from `astro` in dependencies.
|
|
191
|
-
|
|
192
|
-
**Default configuration:**
|
|
193
|
-
|
|
194
|
-
- JSX: `react-jsx`
|
|
195
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
196
|
-
- Types: `astro/client`
|
|
197
|
-
|
|
198
|
-
**Example tsconfig.base.json:**
|
|
199
|
-
|
|
200
|
-
```javascript
|
|
201
|
-
export default await createConfig('typescript', { framework: 'astro' })
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Angular
|
|
205
|
-
|
|
206
|
-
Auto-detected from `@angular/core` in dependencies.
|
|
207
|
-
|
|
208
|
-
**Default configuration:**
|
|
209
|
-
|
|
210
|
-
- Decorators: enabled
|
|
211
|
-
- Emit decorator metadata: enabled
|
|
212
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
213
|
-
|
|
214
|
-
**Example tsconfig.base.json:**
|
|
215
|
-
|
|
216
|
-
```javascript
|
|
217
|
-
export default await createConfig('typescript', { framework: 'angular' })
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Node.js
|
|
221
|
-
|
|
222
|
-
Auto-detected from `type: "module"` without frontend frameworks.
|
|
223
|
-
|
|
224
|
-
**Default configuration:**
|
|
225
|
-
|
|
226
|
-
- Module: `NodeNext`
|
|
227
|
-
- Module Resolution: `NodeNext`
|
|
228
|
-
- Libraries: ES2022 (no DOM)
|
|
229
|
-
- Types: `node`
|
|
230
|
-
|
|
231
|
-
**Example tsconfig.base.json:**
|
|
232
|
-
|
|
233
|
-
```javascript
|
|
234
|
-
export default await createConfig('typescript', { framework: 'node' })
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
**Type checking:**
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
yarn add --save-dev @types/node
|
|
241
|
-
yarn typecheck
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Vanilla JavaScript
|
|
245
|
-
|
|
246
|
-
Default when no framework detected.
|
|
247
|
-
|
|
248
|
-
**Default configuration:**
|
|
249
|
-
|
|
250
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
251
|
-
- Target: ES2020
|
|
252
|
-
|
|
253
|
-
**Example tsconfig.base.json:**
|
|
254
|
-
|
|
255
|
-
```javascript
|
|
256
|
-
export default await createConfig('typescript', { framework: 'vanilla' })
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
## Type Checker Selection
|
|
260
|
-
|
|
261
|
-
The package automatically selects the best type checker for your project:
|
|
262
|
-
|
|
263
|
-
1. **Vue projects:** Prefers `vue-tsc` for .vue file support
|
|
264
|
-
2. **Modern projects:** Uses `tsgo` when installed (10x faster)
|
|
265
|
-
3. **Fallback:** Standard `tsc` for compatibility
|
|
266
|
-
|
|
267
|
-
### Using tsgo (Recommended)
|
|
268
|
-
|
|
269
|
-
tsgo is a Go port of the TypeScript compiler that is 10x faster than tsc.
|
|
270
|
-
|
|
271
|
-
**Installation:**
|
|
272
|
-
|
|
273
|
-
```bash
|
|
274
|
-
yarn add --save-dev @typescript/native-preview
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
**Usage:**
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
yarn tsgo --noEmit
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
The package will automatically detect tsgo and use it when available.
|
|
284
|
-
|
|
285
|
-
### Forcing Checker Preference
|
|
286
|
-
|
|
287
|
-
```javascript
|
|
288
|
-
// Always use tsgo (modern)
|
|
289
|
-
createConfig('typescript', { checker: 'modern' })
|
|
290
|
-
|
|
291
|
-
// Always use tsc/vue-tsc (legacy)
|
|
292
|
-
createConfig('typescript', { checker: 'legacy' })
|
|
293
|
-
|
|
294
|
-
// Auto-detect (default)
|
|
295
|
-
createConfig('typescript', { checker: 'auto' })
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## Environment Detection
|
|
299
|
-
|
|
300
|
-
The package detects three environment types:
|
|
301
|
-
|
|
302
|
-
### Browser
|
|
303
|
-
|
|
304
|
-
**Auto-detected from:**
|
|
305
|
-
|
|
306
|
-
- Frontend framework presence (React, Vue, Svelte, etc.)
|
|
307
|
-
- `type: "module"` without backend indicators
|
|
308
|
-
|
|
309
|
-
**Configuration:**
|
|
310
|
-
|
|
311
|
-
- Target: ES2020
|
|
312
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
313
|
-
|
|
314
|
-
### Node.js
|
|
315
|
-
|
|
316
|
-
**Auto-detected from:**
|
|
317
|
-
|
|
318
|
-
- `type: "module"` without frontend frameworks
|
|
319
|
-
- Backend-only setup
|
|
320
|
-
|
|
321
|
-
**Configuration:**
|
|
322
|
-
|
|
323
|
-
- Target: ES2022
|
|
324
|
-
- Libraries: ES2022 (no DOM)
|
|
325
|
-
- Types: `node`
|
|
326
|
-
|
|
327
|
-
### Universal
|
|
328
|
-
|
|
329
|
-
**Auto-detected from:**
|
|
330
|
-
|
|
331
|
-
- SSR frameworks (Next.js, Nuxt, SvelteKit, Astro)
|
|
332
|
-
- Both browser and Node.js indicators
|
|
333
|
-
|
|
334
|
-
**Configuration:**
|
|
335
|
-
|
|
336
|
-
- Target: ES2020 (browser compatibility)
|
|
337
|
-
- Libraries: ES2022, DOM, DOM.Iterable
|
|
338
|
-
- Types: `node` (for SSR)
|
|
339
|
-
|
|
340
|
-
## Strict Mode
|
|
341
|
-
|
|
342
|
-
Strict mode is enabled by default for better type safety.
|
|
343
|
-
|
|
344
|
-
**Includes:**
|
|
345
|
-
|
|
346
|
-
- `strict: true`
|
|
347
|
-
- `noImplicitAny: true`
|
|
348
|
-
- `strictNullChecks: true`
|
|
349
|
-
- `strictFunctionTypes: true`
|
|
350
|
-
- `strictBindCallApply: true`
|
|
351
|
-
- `strictPropertyInitialization: true`
|
|
352
|
-
- `noImplicitThis: true`
|
|
353
|
-
- `alwaysStrict: true`
|
|
354
|
-
- `noUnusedLocals: true`
|
|
355
|
-
- `noUnusedParameters: true`
|
|
356
|
-
- `noImplicitReturns: true`
|
|
357
|
-
- `noFallthroughCasesInSwitch: true`
|
|
358
|
-
|
|
359
|
-
**Disable strict mode:**
|
|
360
|
-
|
|
361
|
-
```javascript
|
|
362
|
-
createConfig('typescript', { strict: false })
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
This disables `strict`, `noImplicitAny`, `strictNullChecks`, and other strict-related options while keeping quality checks like `noUnusedLocals`.
|
|
366
|
-
|
|
367
|
-
## Advanced Configuration
|
|
368
|
-
|
|
369
|
-
### Path Aliases
|
|
370
|
-
|
|
371
|
-
```javascript
|
|
372
|
-
createConfig('typescript', {
|
|
373
|
-
compilerOptions: {
|
|
374
|
-
baseUrl: '.',
|
|
375
|
-
paths: {
|
|
376
|
-
'@/*': ['src/*'],
|
|
377
|
-
'@components/*': ['src/components/*'],
|
|
378
|
-
'@utils/*': ['src/utils/*']
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
})
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### Custom Output Directory
|
|
385
|
-
|
|
386
|
-
```javascript
|
|
387
|
-
createConfig('typescript', {
|
|
388
|
-
compilerOptions: {
|
|
389
|
-
outDir: './dist',
|
|
390
|
-
rootDir: './src',
|
|
391
|
-
declarationDir: './types'
|
|
392
|
-
}
|
|
393
|
-
})
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### Monorepo Setup
|
|
397
|
-
|
|
398
|
-
```javascript
|
|
399
|
-
createConfig('typescript', {
|
|
400
|
-
compilerOptions: {
|
|
401
|
-
composite: true,
|
|
402
|
-
declarationMap: true,
|
|
403
|
-
incremental: true,
|
|
404
|
-
tsBuildInfoFile: './dist/.tsbuildinfo'
|
|
405
|
-
}
|
|
406
|
-
})
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
### Custom Include/Exclude
|
|
410
|
-
|
|
411
|
-
The base configuration includes sensible defaults:
|
|
412
|
-
|
|
413
|
-
```json
|
|
414
|
-
{
|
|
415
|
-
"include": ["src/**/*"],
|
|
416
|
-
"exclude": ["node_modules", "dist", "build", "out", "coverage", ".nyc_output"]
|
|
417
|
-
}
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
Override these in your `tsconfig.json`:
|
|
421
|
-
|
|
422
|
-
```json
|
|
423
|
-
{
|
|
424
|
-
"extends": "./tsconfig.base.json",
|
|
425
|
-
"include": ["src/**/*", "tests/**/*"],
|
|
426
|
-
"exclude": ["node_modules", "dist", "**/*.spec.ts"]
|
|
427
|
-
}
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
## Helper Functions
|
|
431
|
-
|
|
432
|
-
### detectTypeChecker
|
|
433
|
-
|
|
434
|
-
Get the recommended type checker for your project:
|
|
435
|
-
|
|
436
|
-
```javascript
|
|
437
|
-
import { detectTypeChecker } from '@dimensional-innovations/tool-config/src/tools/typescript/checker-detection.js'
|
|
438
|
-
|
|
439
|
-
const checker = detectTypeChecker('vue', 'auto')
|
|
440
|
-
console.log(checker) // 'vue-tsc', 'tsgo', or 'tsc'
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
### getTypeCheckCommand
|
|
444
|
-
|
|
445
|
-
Generate the appropriate type check command:
|
|
446
|
-
|
|
447
|
-
```javascript
|
|
448
|
-
import { getTypeCheckCommand } from '@dimensional-innovations/tool-config/src/tools/typescript/checker-detection.js'
|
|
449
|
-
|
|
450
|
-
const cmd = getTypeCheckCommand('tsgo', { watch: true })
|
|
451
|
-
console.log(cmd) // 'tsgo --noEmit --watch'
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### getTypeCheckCommandWithFallback
|
|
455
|
-
|
|
456
|
-
Generate a command with fallback to tsc/vue-tsc:
|
|
457
|
-
|
|
458
|
-
```javascript
|
|
459
|
-
import { getTypeCheckCommandWithFallback } from '@dimensional-innovations/tool-config/src/tools/typescript/checker-detection.js'
|
|
460
|
-
|
|
461
|
-
const cmd = getTypeCheckCommandWithFallback('tsgo', 'vue')
|
|
462
|
-
console.log(cmd) // 'tsgo --noEmit || vue-tsc --noEmit'
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
## Troubleshooting
|
|
466
|
-
|
|
467
|
-
### "Cannot find module" errors
|
|
468
|
-
|
|
469
|
-
**Problem:** TypeScript can't find type definitions for dependencies.
|
|
470
|
-
|
|
471
|
-
**Solution:** Install the @types package:
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
yarn add --save-dev @types/node @types/react @types/react-dom
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
### Vue .vue files not type checking
|
|
478
|
-
|
|
479
|
-
**Problem:** `.vue` files showing type errors or not being checked.
|
|
480
|
-
|
|
481
|
-
**Solution:** Install and use vue-tsc:
|
|
482
|
-
|
|
483
|
-
```bash
|
|
484
|
-
yarn add --save-dev vue-tsc
|
|
485
|
-
yarn vue-tsc --noEmit
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
### tsgo not found
|
|
489
|
-
|
|
490
|
-
**Problem:** Package detects tsgo but it's not installed.
|
|
491
|
-
|
|
492
|
-
**Solution:** Install @typescript/native-preview:
|
|
493
|
-
|
|
494
|
-
```bash
|
|
495
|
-
yarn add --save-dev @typescript/native-preview
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
### Slow type checking
|
|
499
|
-
|
|
500
|
-
**Problem:** Type checking is slow in large projects.
|
|
501
|
-
|
|
502
|
-
**Solutions:**
|
|
503
|
-
|
|
504
|
-
1. Install tsgo for 10x faster checking
|
|
505
|
-
2. Enable incremental mode in your tsconfig.json:
|
|
506
|
-
|
|
507
|
-
```json
|
|
508
|
-
{
|
|
509
|
-
"compilerOptions": {
|
|
510
|
-
"incremental": true,
|
|
511
|
-
"tsBuildInfoFile": "./dist/.tsbuildinfo"
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
### Path alias not resolving
|
|
517
|
-
|
|
518
|
-
**Problem:** Import aliases like `@/components` not working.
|
|
519
|
-
|
|
520
|
-
**Solution:** Add path mapping to your config:
|
|
521
|
-
|
|
522
|
-
```javascript
|
|
523
|
-
createConfig('typescript', {
|
|
524
|
-
compilerOptions: {
|
|
525
|
-
baseUrl: '.',
|
|
526
|
-
paths: {
|
|
527
|
-
'@/*': ['src/*']
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
})
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
Also ensure your build tool (Vite, webpack, etc.) is configured to resolve the same aliases.
|
|
534
|
-
|
|
535
|
-
### Strict mode too restrictive
|
|
536
|
-
|
|
537
|
-
**Problem:** Too many type errors in existing codebase.
|
|
538
|
-
|
|
539
|
-
**Solution:** Gradually adopt strict mode:
|
|
540
|
-
|
|
541
|
-
```javascript
|
|
542
|
-
// Disable strict mode initially
|
|
543
|
-
createConfig('typescript', { strict: false })
|
|
544
|
-
|
|
545
|
-
// Or selectively enable strict checks
|
|
546
|
-
createConfig('typescript', {
|
|
547
|
-
strict: false,
|
|
548
|
-
compilerOptions: {
|
|
549
|
-
strictNullChecks: true, // Enable only null checks
|
|
550
|
-
noImplicitAny: true // Enable only implicit any checks
|
|
551
|
-
}
|
|
552
|
-
})
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
## Performance Tips
|
|
556
|
-
|
|
557
|
-
1. **Use tsgo** - Install `@typescript/native-preview` for 10x faster type checking
|
|
558
|
-
2. **Enable incremental** - Set `incremental: true` and `tsBuildInfoFile` in tsconfig
|
|
559
|
-
3. **Use composite projects** - For monorepos, enable `composite: true`
|
|
560
|
-
4. **Skip lib check** - Already enabled by default with `skipLibCheck: true`
|
|
561
|
-
5. **Use project references** - For multi-package repos, use TypeScript project references
|
|
562
|
-
|
|
563
|
-
## Integration with Other Tools
|
|
564
|
-
|
|
565
|
-
### ESLint
|
|
566
|
-
|
|
567
|
-
This package includes ESLint support. Use both together:
|
|
568
|
-
|
|
569
|
-
```javascript
|
|
570
|
-
// eslint.config.js
|
|
571
|
-
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
572
|
-
export default await createConfig('eslint', { framework: 'auto' })
|
|
573
|
-
|
|
574
|
-
// tsconfig.base.json
|
|
575
|
-
export default await createConfig('typescript', { framework: 'auto' })
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
### Prettier
|
|
579
|
-
|
|
580
|
-
Format TypeScript files with Prettier:
|
|
581
|
-
|
|
582
|
-
```javascript
|
|
583
|
-
// prettier.config.js
|
|
584
|
-
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
585
|
-
export default createConfig('prettier', { framework: 'auto' })
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
### Vitest
|
|
589
|
-
|
|
590
|
-
TypeScript works automatically with Vitest. Add to your config:
|
|
591
|
-
|
|
592
|
-
```javascript
|
|
593
|
-
// vitest.config.js
|
|
594
|
-
import { defineConfig } from 'vitest/config'
|
|
595
|
-
|
|
596
|
-
export default defineConfig({
|
|
597
|
-
test: {
|
|
598
|
-
globals: true,
|
|
599
|
-
environment: 'node'
|
|
600
|
-
}
|
|
601
|
-
})
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
## Examples
|
|
605
|
-
|
|
606
|
-
See the [examples directory](../../../examples) for complete TypeScript setup examples:
|
|
607
|
-
|
|
608
|
-
- [React App](../../../examples/react-app)
|
|
609
|
-
- [Vue App](../../../examples/vue-app)
|
|
610
|
-
- [Svelte App](../../../examples/svelte-app)
|
|
611
|
-
- [Solid App](../../../examples/solid-app)
|
|
612
|
-
- [Astro App](../../../examples/astro-app)
|
|
613
|
-
- [Angular App](../../../examples/angular-app)
|
|
614
|
-
- [Vanilla JavaScript](../../../examples/vanilla-js)
|
|
615
|
-
- [Node.js Backend](../../../examples/node-backend)
|
|
616
|
-
|
|
617
|
-
## API Reference
|
|
618
|
-
|
|
619
|
-
### createConfig('typescript', options)
|
|
620
|
-
|
|
621
|
-
**Parameters:**
|
|
622
|
-
|
|
623
|
-
| Option | Type | Default | Description |
|
|
624
|
-
| ----------------- | ------- | --------------- | ---------------------------------------------- |
|
|
625
|
-
| `framework` | string | `'auto'` | Framework type or 'auto' for detection |
|
|
626
|
-
| `environment` | string | `'auto'` | Environment type or 'auto' for detection |
|
|
627
|
-
| `checker` | string | `'auto'` | Checker preference: 'auto', 'modern', 'legacy' |
|
|
628
|
-
| `strict` | boolean | `true` | Enable strict type checking |
|
|
629
|
-
| `compilerOptions` | object | `{}` | Override compiler options |
|
|
630
|
-
| `cwd` | string | `process.cwd()` | Working directory for detection |
|
|
631
|
-
|
|
632
|
-
**Returns:** TypeScript configuration object with metadata
|
|
633
|
-
|
|
634
|
-
**Example:**
|
|
635
|
-
|
|
636
|
-
```javascript
|
|
637
|
-
const config = await createConfig('typescript', {
|
|
638
|
-
framework: 'react',
|
|
639
|
-
environment: 'browser',
|
|
640
|
-
checker: 'modern',
|
|
641
|
-
strict: true,
|
|
642
|
-
compilerOptions: {
|
|
643
|
-
target: 'ES2020',
|
|
644
|
-
baseUrl: '.'
|
|
645
|
-
}
|
|
646
|
-
})
|
|
647
|
-
|
|
648
|
-
console.log(config)
|
|
649
|
-
// {
|
|
650
|
-
// compilerOptions: { ... },
|
|
651
|
-
// include: ['src/**/*'],
|
|
652
|
-
// exclude: ['node_modules', 'dist', ...],
|
|
653
|
-
// _meta: {
|
|
654
|
-
// framework: 'react',
|
|
655
|
-
// environment: 'browser',
|
|
656
|
-
// checker: 'tsgo',
|
|
657
|
-
// experimental: true,
|
|
658
|
-
// generatedBy: '@dimensional-innovations/tool-config'
|
|
659
|
-
// }
|
|
660
|
-
// }
|
|
661
|
-
```
|
|
662
|
-
|
|
663
|
-
## License
|
|
664
|
-
|
|
665
|
-
MIT
|