@typeslayer/validate 0.1.26 → 0.1.27
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/dist/index.d.mts +381 -61
- package/dist/index.mjs +353 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -8
- package/src/index.ts +2 -0
- package/src/trace-json.ts +69 -1
- package/src/types-json.ts +333 -59
package/src/types-json.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import type { SvgIconComponent } from "@mui/icons-material";
|
|
2
|
+
|
|
3
|
+
import AltRoute from "@mui/icons-material/AltRoute";
|
|
4
|
+
import Check from "@mui/icons-material/Check";
|
|
5
|
+
import Close from "@mui/icons-material/Close";
|
|
6
|
+
import Extension from "@mui/icons-material/Extension";
|
|
7
|
+
import FilterListAlt from "@mui/icons-material/FilterListAlt";
|
|
8
|
+
import FindReplace from "@mui/icons-material/FindReplace";
|
|
9
|
+
import Input from "@mui/icons-material/Input";
|
|
10
|
+
import JoinFull from "@mui/icons-material/JoinFull";
|
|
11
|
+
import JoinInner from "@mui/icons-material/JoinInner";
|
|
12
|
+
import Key from "@mui/icons-material/Key";
|
|
13
|
+
import Polyline from "@mui/icons-material/Polyline";
|
|
14
|
+
import QuestionMark from "@mui/icons-material/QuestionMark";
|
|
15
|
+
import Search from "@mui/icons-material/Search";
|
|
16
|
+
import SettingsBackupRestore from "@mui/icons-material/SettingsBackupRestore";
|
|
17
|
+
import SportsKabaddi from "@mui/icons-material/SportsKabaddi";
|
|
18
|
+
import TrackChanges from "@mui/icons-material/TrackChanges";
|
|
19
|
+
|
|
1
20
|
import { z } from "zod/v4";
|
|
2
21
|
import { location, typeId } from "./utils";
|
|
3
22
|
|
|
@@ -101,92 +120,347 @@ const typeRelations = {
|
|
|
101
120
|
};
|
|
102
121
|
|
|
103
122
|
export interface TypeRelationInfo {
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
source: {
|
|
124
|
+
title: string;
|
|
125
|
+
description: string;
|
|
126
|
+
unit: string;
|
|
127
|
+
};
|
|
128
|
+
target: {
|
|
129
|
+
title: string;
|
|
130
|
+
description: string;
|
|
131
|
+
unit: string;
|
|
132
|
+
};
|
|
133
|
+
route: string;
|
|
134
|
+
icon: SvgIconComponent;
|
|
106
135
|
}
|
|
107
136
|
|
|
137
|
+
export const typeRelationOrder = [
|
|
138
|
+
"unionTypes",
|
|
139
|
+
"intersectionTypes",
|
|
140
|
+
"typeArguments",
|
|
141
|
+
"instantiatedType",
|
|
142
|
+
"aliasTypeArguments",
|
|
143
|
+
"conditionalCheckType",
|
|
144
|
+
"conditionalExtendsType",
|
|
145
|
+
"conditionalFalseType",
|
|
146
|
+
"conditionalTrueType",
|
|
147
|
+
"indexedAccessObjectType",
|
|
148
|
+
"indexedAccessIndexType",
|
|
149
|
+
"keyofType",
|
|
150
|
+
"reverseMappedSourceType",
|
|
151
|
+
"reverseMappedMappedType",
|
|
152
|
+
"reverseMappedConstraintType",
|
|
153
|
+
"substitutionBaseType",
|
|
154
|
+
"constraintType",
|
|
155
|
+
"evolvingArrayElementType",
|
|
156
|
+
"evolvingArrayFinalType",
|
|
157
|
+
"aliasType",
|
|
158
|
+
] as const;
|
|
159
|
+
|
|
108
160
|
export const typeRelationInfo = {
|
|
109
|
-
typeArguments: {
|
|
110
|
-
title: "Type Argument",
|
|
111
|
-
unit: "type arguments",
|
|
112
|
-
},
|
|
113
161
|
unionTypes: {
|
|
114
|
-
|
|
115
|
-
|
|
162
|
+
source: {
|
|
163
|
+
title: "Union",
|
|
164
|
+
unit: "union members",
|
|
165
|
+
description:
|
|
166
|
+
"Type whose union has the greatest number of distinct members (breadth of possible shapes).",
|
|
167
|
+
},
|
|
168
|
+
target: {
|
|
169
|
+
title: "Union Member",
|
|
170
|
+
unit: "unions",
|
|
171
|
+
description: "The type most frequently included in unions.",
|
|
172
|
+
},
|
|
173
|
+
route: "union-types",
|
|
174
|
+
icon: JoinFull,
|
|
116
175
|
},
|
|
117
176
|
intersectionTypes: {
|
|
118
|
-
|
|
119
|
-
|
|
177
|
+
source: {
|
|
178
|
+
title: "Intersection",
|
|
179
|
+
unit: "intersections",
|
|
180
|
+
description:
|
|
181
|
+
"Type whose intersection combines the greatest number of constituent types (breadth of constraints).",
|
|
182
|
+
},
|
|
183
|
+
target: {
|
|
184
|
+
title: "Intersection Member",
|
|
185
|
+
unit: "intersections",
|
|
186
|
+
description: "The type most frequently included in intersections.",
|
|
187
|
+
},
|
|
188
|
+
route: "intersection-types",
|
|
189
|
+
icon: JoinInner,
|
|
120
190
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
191
|
+
typeArguments: {
|
|
192
|
+
source: {
|
|
193
|
+
title: "Type Arguments",
|
|
194
|
+
unit: "type arguments",
|
|
195
|
+
description:
|
|
196
|
+
"Generic type with the largest number of supplied type arguments at its most complex instantiation.",
|
|
197
|
+
},
|
|
198
|
+
target: {
|
|
199
|
+
title: "Type Argument",
|
|
200
|
+
unit: "type arguments",
|
|
201
|
+
description:
|
|
202
|
+
"The type most frequently used as a type argument (indicating complex generic interactions).",
|
|
203
|
+
},
|
|
204
|
+
icon: SportsKabaddi,
|
|
205
|
+
route: "type-arguments",
|
|
124
206
|
},
|
|
125
207
|
instantiatedType: {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
208
|
+
source: {
|
|
209
|
+
title: "Instantiated",
|
|
210
|
+
unit: "",
|
|
211
|
+
description: "",
|
|
212
|
+
},
|
|
213
|
+
target: {
|
|
214
|
+
title: "Instantiated By",
|
|
215
|
+
unit: "instantiations",
|
|
216
|
+
description:
|
|
217
|
+
"Type that was instantiated the most, indicating high reuse.",
|
|
218
|
+
},
|
|
219
|
+
icon: Polyline,
|
|
220
|
+
route: "instantiated-type",
|
|
132
221
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
222
|
+
aliasTypeArguments: {
|
|
223
|
+
source: {
|
|
224
|
+
title: "Generic Argument",
|
|
225
|
+
unit: "generic arguments",
|
|
226
|
+
description:
|
|
227
|
+
"Type alias pulling in the greatest number of distinct generic arguments through its resolution layers.",
|
|
228
|
+
},
|
|
229
|
+
target: {
|
|
230
|
+
title: "Generic Arguments",
|
|
231
|
+
unit: "alias type-arguments",
|
|
232
|
+
description:
|
|
233
|
+
'The types most often used as generic arguments. The TypeScript compiler calls this "alias type-arguments." There are technically other kinds of types that can show up here, but it\'s mostly generic type arguments.',
|
|
234
|
+
},
|
|
235
|
+
icon: Input,
|
|
236
|
+
route: "alias-type-arguments",
|
|
144
237
|
},
|
|
145
238
|
conditionalCheckType: {
|
|
146
|
-
|
|
147
|
-
|
|
239
|
+
source: {
|
|
240
|
+
title: "Conditional Check",
|
|
241
|
+
unit: "",
|
|
242
|
+
description: "",
|
|
243
|
+
},
|
|
244
|
+
target: {
|
|
245
|
+
title: "Conditional Check Condition",
|
|
246
|
+
unit: "conditional checks",
|
|
247
|
+
description:
|
|
248
|
+
"Type most often used as the checked type in conditional types (the `T` in `T extends U ? A : B`).",
|
|
249
|
+
},
|
|
250
|
+
icon: QuestionMark,
|
|
251
|
+
route: "conditional-check-type",
|
|
148
252
|
},
|
|
149
253
|
conditionalExtendsType: {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
254
|
+
source: {
|
|
255
|
+
title: "Conditional Extends",
|
|
256
|
+
unit: "",
|
|
257
|
+
description: "",
|
|
258
|
+
},
|
|
259
|
+
target: {
|
|
260
|
+
title: "Conditional Extends",
|
|
261
|
+
unit: "extends uses",
|
|
262
|
+
description:
|
|
263
|
+
"Type most frequently appearing on the `extends` side of conditional types (the `U` in `T extends U ? A : B`)), indicating common constraint relationships.",
|
|
264
|
+
},
|
|
265
|
+
icon: Extension,
|
|
266
|
+
route: "conditional-extends-type",
|
|
156
267
|
},
|
|
157
268
|
conditionalFalseType: {
|
|
158
|
-
|
|
159
|
-
|
|
269
|
+
source: {
|
|
270
|
+
title: "Conditional False",
|
|
271
|
+
unit: "",
|
|
272
|
+
description: "",
|
|
273
|
+
},
|
|
274
|
+
target: {
|
|
275
|
+
title: "Conditional False Branch",
|
|
276
|
+
unit: "false-branch uses",
|
|
277
|
+
description:
|
|
278
|
+
"Type that most often appears as the `false` branch result of conditional types. Indicates fallback/resolution patterns.",
|
|
279
|
+
},
|
|
280
|
+
icon: Close,
|
|
281
|
+
route: "conditional-false-type",
|
|
160
282
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
283
|
+
conditionalTrueType: {
|
|
284
|
+
source: {
|
|
285
|
+
title: "Conditional True",
|
|
286
|
+
unit: "",
|
|
287
|
+
description: "",
|
|
288
|
+
},
|
|
289
|
+
target: {
|
|
290
|
+
title: "Conditional True Branch",
|
|
291
|
+
unit: "true-branch uses",
|
|
292
|
+
description:
|
|
293
|
+
"Type that most often appears as the `true` branch result of conditional types. Indicates favored resolution outcomes.",
|
|
294
|
+
},
|
|
295
|
+
icon: Check,
|
|
296
|
+
route: "conditional-true-type",
|
|
164
297
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
298
|
+
indexedAccessObjectType: {
|
|
299
|
+
source: {
|
|
300
|
+
title: "Indexed Access Object",
|
|
301
|
+
unit: "",
|
|
302
|
+
description: "",
|
|
303
|
+
},
|
|
304
|
+
target: {
|
|
305
|
+
title: "Object Indexed Access By",
|
|
306
|
+
unit: "indexed-accesses",
|
|
307
|
+
description:
|
|
308
|
+
"Type most frequently used as the object operand in indexed access (e.g. `T[K]`), indicating dynamic property shape usage.",
|
|
309
|
+
},
|
|
310
|
+
icon: Search,
|
|
311
|
+
route: "indexed-access-object-type",
|
|
168
312
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
313
|
+
indexedAccessIndexType: {
|
|
314
|
+
source: {
|
|
315
|
+
title: "Indexed Access Index",
|
|
316
|
+
unit: "",
|
|
317
|
+
description: "",
|
|
318
|
+
},
|
|
319
|
+
target: {
|
|
320
|
+
title: "Tuple Indexed Access By",
|
|
321
|
+
unit: "indexed-accesses",
|
|
322
|
+
description:
|
|
323
|
+
"Type most frequently used as the index operand in indexed access of a tuple (e.g. `SomeTuple[K]`).",
|
|
324
|
+
},
|
|
325
|
+
icon: Search,
|
|
326
|
+
route: "indexed-access-index-type",
|
|
172
327
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
328
|
+
keyofType: {
|
|
329
|
+
source: {
|
|
330
|
+
title: "Keyof",
|
|
331
|
+
unit: "",
|
|
332
|
+
description: "",
|
|
333
|
+
},
|
|
334
|
+
target: {
|
|
335
|
+
title: "Keyof Uses",
|
|
336
|
+
unit: "keyof uses",
|
|
337
|
+
description:
|
|
338
|
+
"Type most frequently used within 'keyof' operations, often indicating dynamic property access patterns.",
|
|
339
|
+
},
|
|
340
|
+
icon: Key,
|
|
341
|
+
route: "keyof-type",
|
|
176
342
|
},
|
|
177
343
|
reverseMappedSourceType: {
|
|
178
|
-
|
|
179
|
-
|
|
344
|
+
source: {
|
|
345
|
+
title: "Reverse Mapped Source",
|
|
346
|
+
unit: "",
|
|
347
|
+
description: "",
|
|
348
|
+
},
|
|
349
|
+
target: {
|
|
350
|
+
title: "Reverse-Map Source",
|
|
351
|
+
unit: "reverse-mappings",
|
|
352
|
+
description:
|
|
353
|
+
"Type most commonly appearing as the source in reverse-mapped type transforms (utility mapped types in reverse).",
|
|
354
|
+
},
|
|
355
|
+
icon: SettingsBackupRestore,
|
|
356
|
+
route: "reverse-mapped-source-type",
|
|
180
357
|
},
|
|
181
358
|
reverseMappedMappedType: {
|
|
182
|
-
|
|
183
|
-
|
|
359
|
+
source: {
|
|
360
|
+
title: "Reverse Mapped Mapped",
|
|
361
|
+
unit: "",
|
|
362
|
+
description: "",
|
|
363
|
+
},
|
|
364
|
+
target: {
|
|
365
|
+
title: "Reverse-Map Mapped By",
|
|
366
|
+
unit: "reverse-mapped sources",
|
|
367
|
+
description:
|
|
368
|
+
"Type most commonly produced by reverse-mapped transformations.",
|
|
369
|
+
},
|
|
370
|
+
icon: SettingsBackupRestore,
|
|
371
|
+
route: "reverse-mapped-mapped-type",
|
|
184
372
|
},
|
|
185
373
|
reverseMappedConstraintType: {
|
|
186
|
-
|
|
187
|
-
|
|
374
|
+
source: {
|
|
375
|
+
title: "Reverse Mapped Constraint",
|
|
376
|
+
unit: "",
|
|
377
|
+
description: "",
|
|
378
|
+
},
|
|
379
|
+
target: {
|
|
380
|
+
title: "Reverse-Map Constraints",
|
|
381
|
+
unit: "reverse-mapping constraints",
|
|
382
|
+
description:
|
|
383
|
+
"Type that often serves as a constraint in reverse-mapped transformations, indicating mapped type bounds.",
|
|
384
|
+
},
|
|
385
|
+
icon: SettingsBackupRestore,
|
|
386
|
+
route: "reverse-mapped-constraint-type",
|
|
387
|
+
},
|
|
388
|
+
substitutionBaseType: {
|
|
389
|
+
source: {
|
|
390
|
+
title: "Substitution Base",
|
|
391
|
+
unit: "",
|
|
392
|
+
description: "",
|
|
393
|
+
},
|
|
394
|
+
target: {
|
|
395
|
+
title: "Substitution Bases",
|
|
396
|
+
unit: "substitution uses",
|
|
397
|
+
description:
|
|
398
|
+
"Type used as a substitution base during type substitution operations, signaling types that commonly serve as generic inference placeholders.",
|
|
399
|
+
},
|
|
400
|
+
icon: FindReplace,
|
|
401
|
+
route: "substitution-base-type",
|
|
402
|
+
},
|
|
403
|
+
constraintType: {
|
|
404
|
+
source: {
|
|
405
|
+
title: "Constraint",
|
|
406
|
+
unit: "",
|
|
407
|
+
description: "",
|
|
408
|
+
},
|
|
409
|
+
target: {
|
|
410
|
+
title: "Generic Constraints",
|
|
411
|
+
unit: "constraint uses",
|
|
412
|
+
description:
|
|
413
|
+
"Type most often appearing as a generic constraint (e.g. in `extends` clauses) when resolving generics and conditionals.",
|
|
414
|
+
},
|
|
415
|
+
icon: FilterListAlt,
|
|
416
|
+
route: "constraint-type",
|
|
417
|
+
},
|
|
418
|
+
evolvingArrayElementType: {
|
|
419
|
+
source: {
|
|
420
|
+
title: "Evolving Array Element",
|
|
421
|
+
unit: "",
|
|
422
|
+
description: "",
|
|
423
|
+
},
|
|
424
|
+
target: {
|
|
425
|
+
title: "Evolving Array Element",
|
|
426
|
+
unit: "array element uses",
|
|
427
|
+
description:
|
|
428
|
+
"Type most commonly used as the evolving array element during array widening/folding operations in inference.",
|
|
429
|
+
},
|
|
430
|
+
icon: TrackChanges,
|
|
431
|
+
route: "evolving-array-element-type",
|
|
432
|
+
},
|
|
433
|
+
evolvingArrayFinalType: {
|
|
434
|
+
source: {
|
|
435
|
+
title: "Evolving Array Final",
|
|
436
|
+
unit: "",
|
|
437
|
+
description: "",
|
|
438
|
+
},
|
|
439
|
+
target: {
|
|
440
|
+
title: "Evolving Array Final",
|
|
441
|
+
unit: "array final uses",
|
|
442
|
+
description:
|
|
443
|
+
"Type that frequently becomes the final element type after array evolution/widening, useful to spot common widened shapes.",
|
|
444
|
+
},
|
|
445
|
+
icon: TrackChanges,
|
|
446
|
+
route: "evolving-array-final-type",
|
|
447
|
+
},
|
|
448
|
+
aliasType: {
|
|
449
|
+
source: {
|
|
450
|
+
title: "Alias",
|
|
451
|
+
unit: "",
|
|
452
|
+
description: "",
|
|
453
|
+
},
|
|
454
|
+
target: {
|
|
455
|
+
title: "Aliased As",
|
|
456
|
+
unit: "alias uses",
|
|
457
|
+
description:
|
|
458
|
+
"Type most frequently used as an alias target, shows which aliases are heavily reused across the codebase.",
|
|
459
|
+
},
|
|
460
|
+
icon: AltRoute,
|
|
461
|
+
route: "alias-type",
|
|
188
462
|
},
|
|
189
|
-
} satisfies Record<keyof typeof typeRelations, TypeRelationInfo>;
|
|
463
|
+
} as const satisfies Record<keyof typeof typeRelations, TypeRelationInfo>;
|
|
190
464
|
|
|
191
465
|
export const resolvedType = z
|
|
192
466
|
.object({
|