@shibanet0/datamitsu-config 0.0.3-alpha-18 → 0.0.3-alpha-19
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/TSCONFIG.md +244 -0
- package/datamitsu.config.js +1 -1
- package/dist/datamitsu.config.d.ts +17 -0
- package/package.json +4 -3
package/TSCONFIG.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# TypeScript Configuration Guide
|
|
2
|
+
|
|
3
|
+
This package provides reusable TypeScript configurations for different project types.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- **TypeScript 6.0+** required
|
|
8
|
+
- Modern bundler (tsup, vite, esbuild)
|
|
9
|
+
|
|
10
|
+
## Quick Selection
|
|
11
|
+
|
|
12
|
+
| Project Type | Monorepo? | Config |
|
|
13
|
+
| ------------------- | --------- | ----------------------------- |
|
|
14
|
+
| Next.js app | Any | `nextjs.json` |
|
|
15
|
+
| React + Vite app | Any | `base.json` |
|
|
16
|
+
| React library | Yes | `shared-react-library.json` |
|
|
17
|
+
| React library | No | `react-library.json` |
|
|
18
|
+
| Node.js library | Yes | `shared-library.json` |
|
|
19
|
+
| Node.js library | No | `library.json` |
|
|
20
|
+
| Backend API/service | Any | `service.json` |
|
|
21
|
+
| Node.js CLI | Any | `base.json` or `service.json` |
|
|
22
|
+
| E2E tests | Any | `base.json` |
|
|
23
|
+
|
|
24
|
+
## Configuration Descriptions
|
|
25
|
+
|
|
26
|
+
### `base.json`
|
|
27
|
+
|
|
28
|
+
**For:** CLI tools, tests, build scripts, React apps (Vite, CRA)
|
|
29
|
+
|
|
30
|
+
**Features:**
|
|
31
|
+
|
|
32
|
+
- Strict typing by default
|
|
33
|
+
- `src/` → `dist/` structure
|
|
34
|
+
- Explicit configuration (all options specified)
|
|
35
|
+
|
|
36
|
+
**Example:**
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"extends": "@shibanet0/datamitsu-config/tsconfig/base.json"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### `library.json`
|
|
47
|
+
|
|
48
|
+
**For:** Standalone npm package (NOT in monorepo)
|
|
49
|
+
|
|
50
|
+
**Adds:** `noEmit: true` - bundler handles all output
|
|
51
|
+
|
|
52
|
+
**Example:** Standalone npm utility package
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### `react-library.json`
|
|
57
|
+
|
|
58
|
+
**For:** Standalone React library (NOT in monorepo)
|
|
59
|
+
|
|
60
|
+
**Adds:**
|
|
61
|
+
|
|
62
|
+
- DOM types
|
|
63
|
+
- JSX support
|
|
64
|
+
- `noEmit: true`
|
|
65
|
+
|
|
66
|
+
**⚠️ WARNING:** DO NOT use for Node.js projects! Adds DOM types that don't exist in Node.js.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### `service.json`
|
|
71
|
+
|
|
72
|
+
**For:** Backend APIs, serverless functions, microservices
|
|
73
|
+
|
|
74
|
+
**Adds:**
|
|
75
|
+
|
|
76
|
+
- `types: ["node"]`
|
|
77
|
+
- `noEmit: true`
|
|
78
|
+
|
|
79
|
+
**Example:** Express API, AWS Lambda
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `shared-library.json`
|
|
84
|
+
|
|
85
|
+
**For:** Library INSIDE a monorepo
|
|
86
|
+
|
|
87
|
+
**Adds:**
|
|
88
|
+
|
|
89
|
+
- `composite: true` - project references
|
|
90
|
+
- `declaration: true` - emits .d.ts
|
|
91
|
+
- `declarationMap: true`
|
|
92
|
+
|
|
93
|
+
**Why NOT noEmit:** Project references require TypeScript to emit declarations for IDE "go to definition".
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### `shared-react-library.json`
|
|
98
|
+
|
|
99
|
+
**For:** React library INSIDE a monorepo
|
|
100
|
+
|
|
101
|
+
**Adds:**
|
|
102
|
+
|
|
103
|
+
- DOM types + JSX
|
|
104
|
+
- `composite: true`
|
|
105
|
+
- Declaration emit
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### `nextjs.json`
|
|
110
|
+
|
|
111
|
+
**For:** Next.js apps (Pages/App Router)
|
|
112
|
+
|
|
113
|
+
**Features:**
|
|
114
|
+
|
|
115
|
+
- `jsx: "preserve"` - Next.js transforms itself
|
|
116
|
+
- `noEmit: true`
|
|
117
|
+
- Next.js plugin
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Common Mistakes
|
|
122
|
+
|
|
123
|
+
### ❌ react-library for Node.js projects
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
// WRONG for Node.js API
|
|
127
|
+
{
|
|
128
|
+
"extends": "@shibanet0/datamitsu-config/tsconfig/react-library.json"
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Problem:** Adds DOM types (`document`, `window`) to Node.js environment.
|
|
133
|
+
|
|
134
|
+
**Solution:** Use `service.json`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### ❌ library instead of shared-library in monorepo
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
// WRONG in monorepo
|
|
142
|
+
{
|
|
143
|
+
"extends": "@shibanet0/datamitsu-config/tsconfig/library.json"
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Problem:** `noEmit: true` disables declaration emit, IDE can't "go to definition".
|
|
148
|
+
|
|
149
|
+
**Solution:** Use `shared-library.json`
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### ❌ Forgot explicit types after TS6
|
|
154
|
+
|
|
155
|
+
**Problem:**
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { readFile } from "node:fs/promises";
|
|
159
|
+
// Error: Cannot find module 'node:fs/promises'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Solution:**
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"extends": "@shibanet0/datamitsu-config/tsconfig/service.json",
|
|
167
|
+
"compilerOptions": {
|
|
168
|
+
"types": ["node"]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Path Aliases
|
|
176
|
+
|
|
177
|
+
**These configurations DO NOT include path aliases (`~/*`, `@/*`).**
|
|
178
|
+
|
|
179
|
+
**Why?**
|
|
180
|
+
|
|
181
|
+
- Require duplication in tsconfig, bundler, jest, eslint
|
|
182
|
+
- Problems when publishing libraries
|
|
183
|
+
- Different syntax across tools
|
|
184
|
+
|
|
185
|
+
**Use relative paths:**
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { helper } from "../../utils/helper";
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Benefits:**
|
|
192
|
+
|
|
193
|
+
- Work everywhere without configuration
|
|
194
|
+
- ES modules standard
|
|
195
|
+
- IDE auto-updates
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Philosophy
|
|
200
|
+
|
|
201
|
+
**Bundler-centric approach:**
|
|
202
|
+
|
|
203
|
+
- TypeScript only for type checking
|
|
204
|
+
- Bundler handles compilation, sourcemaps, declarations
|
|
205
|
+
- Exception: monorepo `shared-*` configs emit declarations for project references
|
|
206
|
+
|
|
207
|
+
**Explicit configuration:**
|
|
208
|
+
|
|
209
|
+
- All options specified explicitly, even if they're TS6 defaults
|
|
210
|
+
- No magic, maximum compatibility
|
|
211
|
+
- "Just works" everywhere
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Migration to TS6
|
|
216
|
+
|
|
217
|
+
**TypeScript 6.0+ required:**
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
pnpm add -D typescript@latest
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Add explicit types:**
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"extends": "@shibanet0/datamitsu-config/tsconfig/service.json",
|
|
228
|
+
"compilerOptions": {
|
|
229
|
+
"types": ["node"]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Check types:**
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
tsc --noEmit
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Based on
|
|
243
|
+
|
|
244
|
+
[@codecompose/typescript-config](https://github.com/0x80/typescript-config) by 0x80.
|
package/datamitsu.config.js
CHANGED
|
@@ -3118,7 +3118,7 @@ const mapOfApps = {
|
|
|
3118
3118
|
//#endregion
|
|
3119
3119
|
//#region package.json
|
|
3120
3120
|
var name = "@shibanet0/datamitsu-config";
|
|
3121
|
-
var version = "0.0.3-alpha-
|
|
3121
|
+
var version = "0.0.3-alpha-19";
|
|
3122
3122
|
|
|
3123
3123
|
//#endregion
|
|
3124
3124
|
//#region src/apps/oxlint/index.ts
|
|
@@ -246,6 +246,23 @@ declare global {
|
|
|
246
246
|
*/
|
|
247
247
|
function linkPath(ownerName: string, linkName: string, fromPath: string): string;
|
|
248
248
|
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Hashing utilities for content verification and change detection.
|
|
252
|
+
*/
|
|
253
|
+
namespace Hash {
|
|
254
|
+
/**
|
|
255
|
+
* Asserts content matches expectedHash (BLAKE2b-256).
|
|
256
|
+
* No-op if hashes match. If mismatched: prints file name + current hash to stderr and throws.
|
|
257
|
+
* Pass hash: "" on first use — the error will show the hash to copy.
|
|
258
|
+
* @throws Error if hashes do not match
|
|
259
|
+
*/
|
|
260
|
+
function assert(opts: { content: string; file: string; hash: string }): void;
|
|
261
|
+
/** BLAKE2b-256 hex digest. Fast; used internally by assert(). */
|
|
262
|
+
function blake2b256(content: string): string;
|
|
263
|
+
/** SHA-256 hex digest. */
|
|
264
|
+
function sha256(content: string): string;
|
|
265
|
+
}
|
|
249
266
|
}
|
|
250
267
|
|
|
251
268
|
namespace config {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shibanet0/datamitsu-config",
|
|
3
|
-
"version": "0.0.3-alpha-
|
|
3
|
+
"version": "0.0.3-alpha-19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"datamitsu.config.d.ts",
|
|
39
39
|
"tsconfig/**",
|
|
40
40
|
"dist/**",
|
|
41
|
-
"bin/**"
|
|
41
|
+
"bin/**",
|
|
42
|
+
"TSCONFIG.md"
|
|
42
43
|
],
|
|
43
44
|
"scripts": {
|
|
44
45
|
"preinstall": "npx only-allow@1.2.2 pnpm",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@commander-js/extra-typings": "14.0.0",
|
|
49
|
-
"@datamitsu/datamitsu": "0.0.3-alpha-
|
|
50
|
+
"@datamitsu/datamitsu": "0.0.3-alpha-20",
|
|
50
51
|
"commander": "14.0.3",
|
|
51
52
|
"execa": "9.6.1",
|
|
52
53
|
"fast-glob": "3.3.3",
|