@sinclair/typebox 0.33.19 → 0.33.20

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 (67) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +5 -1
  3. package/build/cjs/parse/index.d.ts +1 -0
  4. package/build/cjs/parse/index.js +18 -0
  5. package/build/cjs/parse/parse.d.ts +11 -0
  6. package/build/cjs/parse/parse.js +18 -0
  7. package/build/cjs/parse/parsebox/index.d.ts +2 -0
  8. package/build/cjs/parse/parsebox/index.js +6 -0
  9. package/build/cjs/parse/parsebox/runtime/guard.d.ts +17 -0
  10. package/build/cjs/parse/parsebox/runtime/guard.js +75 -0
  11. package/build/cjs/parse/parsebox/runtime/index.d.ts +5 -0
  12. package/build/cjs/parse/parsebox/runtime/index.js +23 -0
  13. package/build/cjs/parse/parsebox/runtime/module.d.ts +9 -0
  14. package/build/cjs/parse/parsebox/runtime/module.js +22 -0
  15. package/build/cjs/parse/parsebox/runtime/parse.d.ts +9 -0
  16. package/build/cjs/parse/parsebox/runtime/parse.js +99 -0
  17. package/build/cjs/parse/parsebox/runtime/token.d.ts +8 -0
  18. package/build/cjs/parse/parsebox/runtime/token.js +230 -0
  19. package/build/cjs/parse/parsebox/runtime/types.d.ts +68 -0
  20. package/build/cjs/parse/parsebox/runtime/types.js +45 -0
  21. package/build/cjs/parse/parsebox/static/index.d.ts +3 -0
  22. package/build/cjs/parse/parsebox/static/index.js +21 -0
  23. package/build/cjs/parse/parsebox/static/parse.d.ts +17 -0
  24. package/build/cjs/parse/parsebox/static/parse.js +3 -0
  25. package/build/cjs/parse/parsebox/static/token.d.ts +108 -0
  26. package/build/cjs/parse/parsebox/static/token.js +3 -0
  27. package/build/cjs/parse/parsebox/static/types.d.ts +46 -0
  28. package/build/cjs/parse/parsebox/static/types.js +3 -0
  29. package/build/cjs/parse/runtime.d.ts +55 -0
  30. package/build/cjs/parse/runtime.js +621 -0
  31. package/build/cjs/parse/static.d.ts +471 -0
  32. package/build/cjs/parse/static.js +3 -0
  33. package/build/esm/index.d.mts +1 -0
  34. package/build/esm/index.mjs +5 -1
  35. package/build/esm/parse/index.d.mts +1 -0
  36. package/build/esm/parse/index.mjs +1 -0
  37. package/build/esm/parse/parse.d.mts +11 -0
  38. package/build/esm/parse/parse.mjs +13 -0
  39. package/build/esm/parse/parsebox/index.d.mts +2 -0
  40. package/build/esm/parse/parsebox/index.mjs +2 -0
  41. package/build/esm/parse/parsebox/runtime/guard.d.mts +17 -0
  42. package/build/esm/parse/parsebox/runtime/guard.mjs +64 -0
  43. package/build/esm/parse/parsebox/runtime/index.d.mts +5 -0
  44. package/build/esm/parse/parsebox/runtime/index.mjs +5 -0
  45. package/build/esm/parse/parsebox/runtime/module.d.mts +9 -0
  46. package/build/esm/parse/parsebox/runtime/module.mjs +17 -0
  47. package/build/esm/parse/parsebox/runtime/parse.d.mts +9 -0
  48. package/build/esm/parse/parsebox/runtime/parse.mjs +95 -0
  49. package/build/esm/parse/parsebox/runtime/token.d.mts +8 -0
  50. package/build/esm/parse/parsebox/runtime/token.mjs +223 -0
  51. package/build/esm/parse/parsebox/runtime/types.d.mts +68 -0
  52. package/build/esm/parse/parsebox/runtime/types.mjs +32 -0
  53. package/build/esm/parse/parsebox/static/index.d.mts +3 -0
  54. package/build/esm/parse/parsebox/static/index.mjs +3 -0
  55. package/build/esm/parse/parsebox/static/parse.d.mts +17 -0
  56. package/build/esm/parse/parsebox/static/parse.mjs +1 -0
  57. package/build/esm/parse/parsebox/static/token.d.mts +108 -0
  58. package/build/esm/parse/parsebox/static/token.mjs +1 -0
  59. package/build/esm/parse/parsebox/static/types.d.mts +46 -0
  60. package/build/esm/parse/parsebox/static/types.mjs +1 -0
  61. package/build/esm/parse/runtime.d.mts +55 -0
  62. package/build/esm/parse/runtime.mjs +617 -0
  63. package/build/esm/parse/static.d.mts +471 -0
  64. package/build/esm/parse/static.mjs +1 -0
  65. package/package.json +11 -1
  66. package/parse/package.json +4 -0
  67. package/readme.md +5 -4
@@ -0,0 +1,55 @@
1
+ import { Runtime } from './parsebox/index.mjs';
2
+ import * as Types from '../type/index.mjs';
3
+ export declare const Module: Runtime.Module<{
4
+ Literal: Runtime.IUnion<Types.TLiteral<string> | Types.TLiteral<number> | Types.TLiteral<boolean>>;
5
+ Keyword: Runtime.IUnion<Types.TAny | Types.TNever | Types.TString | Types.TBoolean | Types.TNumber | Types.TInteger | Types.TBigInt | Types.TNull | Types.TSymbol | Types.TUndefined | Types.TUnknown | Types.TVoid>;
6
+ KeyOf: Runtime.IUnion<boolean>;
7
+ IndexArray: Runtime.IUnion<unknown[]>;
8
+ Extends: Runtime.IUnion<unknown[]>;
9
+ Base: Runtime.IUnion<unknown>;
10
+ Factor: Runtime.ITuple<Types.TSchema>;
11
+ ExprTermTail: Runtime.IUnion<[] | ["&", unknown, unknown]>;
12
+ ExprTerm: Runtime.ITuple<Types.TSchema>;
13
+ ExprTail: Runtime.IUnion<[] | ["|", unknown, unknown]>;
14
+ Expr: Runtime.ITuple<Types.TSchema>;
15
+ Type: Runtime.IRef<unknown>;
16
+ PropertyKey: Runtime.IUnion<string>;
17
+ PropertyReadonly: Runtime.IUnion<boolean>;
18
+ PropertyOptional: Runtime.IUnion<boolean>;
19
+ Property: Runtime.ITuple<{
20
+ [x: string]: Types.TSchema;
21
+ }>;
22
+ PropertyDelimiter: Runtime.IUnion<[","] | [",", "\n"] | [";"] | [";", "\n"] | ["\n"]>;
23
+ Properties: Runtime.IUnion<unknown[]>;
24
+ Object: Runtime.ITuple<Types.TObject<Record<string, Types.TSchema>>>;
25
+ Elements: Runtime.IUnion<unknown[]>;
26
+ Tuple: Runtime.ITuple<Types.TTuple<Types.TSchema[]>>;
27
+ Parameter: Runtime.ITuple<Types.TSchema>;
28
+ Function: Runtime.ITuple<Types.TFunction<Types.TSchema[], Types.TSchema>>;
29
+ Parameters: Runtime.IUnion<unknown[]>;
30
+ Constructor: Runtime.ITuple<Types.TConstructor<Types.TSchema[], Types.TSchema>>;
31
+ Mapped: Runtime.ITuple<Types.TLiteral<"Mapped types not supported">>;
32
+ AsyncIterator: Runtime.ITuple<Types.TAsyncIterator<Types.TSchema>>;
33
+ Iterator: Runtime.ITuple<Types.TIterator<Types.TSchema>>;
34
+ Awaited: Runtime.ITuple<Types.TSchema>;
35
+ Array: Runtime.ITuple<Types.TArray<Types.TSchema>>;
36
+ Record: Runtime.ITuple<Types.TNever>;
37
+ Promise: Runtime.ITuple<Types.TPromise<Types.TSchema>>;
38
+ ConstructorParameters: Runtime.ITuple<Types.TTuple<Types.TSchema[]>>;
39
+ FunctionParameters: Runtime.ITuple<Types.TTuple<Types.TSchema[]>>;
40
+ InstanceType: Runtime.ITuple<Types.TSchema>;
41
+ ReturnType: Runtime.ITuple<Types.TSchema>;
42
+ Partial: Runtime.ITuple<Types.TObject<{}>>;
43
+ Required: Runtime.ITuple<Types.TObject<{}>>;
44
+ Pick: Runtime.ITuple<Types.TObject<{}>>;
45
+ Omit: Runtime.ITuple<Types.TObject<{}>>;
46
+ Exclude: Runtime.ITuple<Types.TNever>;
47
+ Extract: Runtime.ITuple<Types.TSchema>;
48
+ Uppercase: Runtime.ITuple<Types.TSchema>;
49
+ Lowercase: Runtime.ITuple<Types.TSchema>;
50
+ Capitalize: Runtime.ITuple<Types.TSchema>;
51
+ Uncapitalize: Runtime.ITuple<Types.TSchema>;
52
+ Date: Runtime.IConst<Types.TDate>;
53
+ Uint8Array: Runtime.IConst<Types.TUint8Array>;
54
+ Reference: Runtime.IIdent<Types.TSchema>;
55
+ }>;
@@ -0,0 +1,617 @@
1
+ import { Runtime } from './parsebox/index.mjs';
2
+ import * as Types from '../type/index.mjs';
3
+ // ------------------------------------------------------------------
4
+ // Tokens
5
+ // ------------------------------------------------------------------
6
+ const Newline = '\n';
7
+ const LBracket = '[';
8
+ const RBracket = ']';
9
+ const LParen = '(';
10
+ const RParen = ')';
11
+ const LBrace = '{';
12
+ const RBrace = '}';
13
+ const LAngle = '<';
14
+ const RAngle = '>';
15
+ const Question = '?';
16
+ const Colon = ':';
17
+ const Comma = ',';
18
+ const SemiColon = ';';
19
+ const SingleQuote = "'";
20
+ const DoubleQuote = '"';
21
+ const Tilde = '`';
22
+ // ------------------------------------------------------------------
23
+ // DestructureRight
24
+ // ------------------------------------------------------------------
25
+ // prettier-ignore
26
+ function DestructureRight(values) {
27
+ return (values.length > 0)
28
+ ? [values.slice(0, values.length - 1), values[values.length - 1]]
29
+ : [values, undefined];
30
+ }
31
+ // ------------------------------------------------------------------
32
+ // Reference
33
+ // ------------------------------------------------------------------
34
+ // prettier-ignore
35
+ const Reference = Runtime.Ident((value, context) => {
36
+ return value in context ? context[value] : Types.Ref(value);
37
+ });
38
+ // ------------------------------------------------------------------
39
+ // Literal
40
+ // ------------------------------------------------------------------
41
+ // prettier-ignore
42
+ const Literal = Runtime.Union([
43
+ Runtime.Union([Runtime.Const('true'), Runtime.Const('false')], value => Types.Literal(value === 'true')),
44
+ Runtime.Number(value => Types.Literal(parseFloat(value))),
45
+ Runtime.String([SingleQuote, DoubleQuote, Tilde], value => Types.Literal(value))
46
+ ]);
47
+ // ------------------------------------------------------------------
48
+ // Keyword
49
+ // ------------------------------------------------------------------
50
+ // prettier-ignore
51
+ const Keyword = Runtime.Union([
52
+ Runtime.Const('any', Runtime.As(Types.Any())),
53
+ Runtime.Const('bigint', Runtime.As(Types.BigInt())),
54
+ Runtime.Const('boolean', Runtime.As(Types.Boolean())),
55
+ Runtime.Const('integer', Runtime.As(Types.Integer())),
56
+ Runtime.Const('never', Runtime.As(Types.Never())),
57
+ Runtime.Const('null', Runtime.As(Types.Null())),
58
+ Runtime.Const('number', Runtime.As(Types.Number())),
59
+ Runtime.Const('string', Runtime.As(Types.String())),
60
+ Runtime.Const('symbol', Runtime.As(Types.Symbol())),
61
+ Runtime.Const('undefined', Runtime.As(Types.Undefined())),
62
+ Runtime.Const('unknown', Runtime.As(Types.Unknown())),
63
+ Runtime.Const('void', Runtime.As(Types.Void())),
64
+ ]);
65
+ // ------------------------------------------------------------------
66
+ // KeyOf
67
+ // ------------------------------------------------------------------
68
+ // prettier-ignore
69
+ const KeyOfMapping = (values) => (values.length > 0);
70
+ // prettier-ignore
71
+ const KeyOf = Runtime.Union([
72
+ Runtime.Tuple([Runtime.Const('keyof')]), Runtime.Tuple([])
73
+ ], KeyOfMapping);
74
+ // ------------------------------------------------------------------
75
+ // IndexArray
76
+ // ------------------------------------------------------------------
77
+ // prettier-ignore
78
+ const IndexArrayMapping = (values) => (values.length === 4 ? [[values[1]], ...values[3]] :
79
+ values.length === 3 ? [[], ...values[2]] :
80
+ []);
81
+ // prettier-ignore
82
+ const IndexArray = Runtime.Union([
83
+ Runtime.Tuple([Runtime.Const(LBracket), Runtime.Ref('Type'), Runtime.Const(RBracket), Runtime.Ref('IndexArray')]),
84
+ Runtime.Tuple([Runtime.Const(LBracket), Runtime.Const(RBracket), Runtime.Ref('IndexArray')]),
85
+ Runtime.Tuple([])
86
+ ], value => IndexArrayMapping(value));
87
+ // ------------------------------------------------------------------
88
+ // Extends
89
+ // ------------------------------------------------------------------
90
+ // prettier-ignore
91
+ const ExtendsMapping = (values) => {
92
+ return values.length === 6
93
+ ? [values[1], values[3], values[5]]
94
+ : [];
95
+ };
96
+ // prettier-ignore
97
+ const Extends = Runtime.Union([
98
+ Runtime.Tuple([Runtime.Const('extends'), Runtime.Ref('Type'), Runtime.Const(Question), Runtime.Ref('Type'), Runtime.Const(Colon), Runtime.Ref('Type')]),
99
+ Runtime.Tuple([])
100
+ ], ExtendsMapping);
101
+ // ------------------------------------------------------------------
102
+ // Base
103
+ // ------------------------------------------------------------------
104
+ // prettier-ignore
105
+ const BaseMapping = (values) => {
106
+ return values.length === 3 ? values[1] : values[0];
107
+ };
108
+ // prettier-ignore
109
+ const Base = Runtime.Union([
110
+ Runtime.Tuple([
111
+ Runtime.Const(LParen),
112
+ Runtime.Ref('Type'),
113
+ Runtime.Const(RParen)
114
+ ]),
115
+ Runtime.Tuple([Runtime.Union([
116
+ Runtime.Ref('Literal'),
117
+ Runtime.Ref('Keyword'),
118
+ Runtime.Ref('Object'),
119
+ Runtime.Ref('Tuple'),
120
+ Runtime.Ref('Constructor'),
121
+ Runtime.Ref('Function'),
122
+ Runtime.Ref('Mapped'),
123
+ Runtime.Ref('AsyncIterator'),
124
+ Runtime.Ref('Iterator'),
125
+ Runtime.Ref('ConstructorParameters'),
126
+ Runtime.Ref('FunctionParameters'),
127
+ Runtime.Ref('InstanceType'),
128
+ Runtime.Ref('ReturnType'),
129
+ Runtime.Ref('Awaited'),
130
+ Runtime.Ref('Array'),
131
+ Runtime.Ref('Record'),
132
+ Runtime.Ref('Promise'),
133
+ Runtime.Ref('Partial'),
134
+ Runtime.Ref('Required'),
135
+ Runtime.Ref('Pick'),
136
+ Runtime.Ref('Omit'),
137
+ Runtime.Ref('Exclude'),
138
+ Runtime.Ref('Extract'),
139
+ Runtime.Ref('Uppercase'),
140
+ Runtime.Ref('Lowercase'),
141
+ Runtime.Ref('Capitalize'),
142
+ Runtime.Ref('Uncapitalize'),
143
+ Runtime.Ref('Date'),
144
+ Runtime.Ref('Uint8Array'),
145
+ Runtime.Ref('Reference')
146
+ ])])
147
+ ], BaseMapping);
148
+ // ------------------------------------------------------------------
149
+ // Factor
150
+ // ------------------------------------------------------------------
151
+ // prettier-ignore
152
+ const FactorExtends = (Type, Extends) => {
153
+ return Extends.length === 3
154
+ ? Types.Extends(Type, Extends[0], Extends[1], Extends[2])
155
+ : Type;
156
+ };
157
+ // prettier-ignore
158
+ const FactorIndexArray = (Type, IndexArray) => {
159
+ const [Left, Right] = DestructureRight(IndexArray);
160
+ return (!Types.ValueGuard.IsUndefined(Right) ? (Right.length === 1 ? Types.Index(FactorIndexArray(Type, Left), Right[0]) :
161
+ Right.length === 0 ? Types.Array(FactorIndexArray(Type, Left)) :
162
+ Types.Never()) : Type);
163
+ };
164
+ // prettier-ignore
165
+ const FactorMapping = (KeyOf, Type, IndexArray, Extends) => {
166
+ return KeyOf
167
+ ? FactorExtends(Types.KeyOf(FactorIndexArray(Type, IndexArray)), Extends)
168
+ : FactorExtends(FactorIndexArray(Type, IndexArray), Extends);
169
+ };
170
+ // prettier-ignore
171
+ const Factor = Runtime.Tuple([
172
+ Runtime.Ref('KeyOf'),
173
+ Runtime.Ref('Base'),
174
+ Runtime.Ref('IndexArray'),
175
+ Runtime.Ref('Extends')
176
+ ], values => FactorMapping(...values));
177
+ // ------------------------------------------------------------------
178
+ // Expr
179
+ // ------------------------------------------------------------------
180
+ // prettier-ignore
181
+ function ExprBinaryMapping(Left, Rest) {
182
+ return (Rest.length === 3 ? (() => {
183
+ const [Operator, Right, Next] = Rest;
184
+ const Schema = ExprBinaryMapping(Right, Next);
185
+ if (Operator === '&') {
186
+ return Types.TypeGuard.IsIntersect(Schema)
187
+ ? Types.Intersect([Left, ...Schema.allOf])
188
+ : Types.Intersect([Left, Schema]);
189
+ }
190
+ if (Operator === '|') {
191
+ return Types.TypeGuard.IsUnion(Schema)
192
+ ? Types.Union([Left, ...Schema.anyOf])
193
+ : Types.Union([Left, Schema]);
194
+ }
195
+ throw 1;
196
+ })() : Left);
197
+ }
198
+ // prettier-ignore
199
+ const ExprTermTail = Runtime.Union([
200
+ Runtime.Tuple([Runtime.Const('&'), Runtime.Ref('Factor'), Runtime.Ref('ExprTermTail')]),
201
+ Runtime.Tuple([])
202
+ ]);
203
+ // prettier-ignore
204
+ const ExprTerm = Runtime.Tuple([
205
+ Runtime.Ref('Factor'), Runtime.Ref('ExprTermTail')
206
+ ], value => ExprBinaryMapping(...value));
207
+ // prettier-ignore
208
+ const ExprTail = Runtime.Union([
209
+ Runtime.Tuple([Runtime.Const('|'), Runtime.Ref('ExprTerm'), Runtime.Ref('ExprTail')]),
210
+ Runtime.Tuple([])
211
+ ]);
212
+ // prettier-ignore
213
+ const Expr = Runtime.Tuple([
214
+ Runtime.Ref('ExprTerm'), Runtime.Ref('ExprTail')
215
+ ], value => ExprBinaryMapping(...value));
216
+ // ------------------------------------------------------------------
217
+ // Type
218
+ // ------------------------------------------------------------------
219
+ const Type = Runtime.Ref('Expr');
220
+ // ------------------------------------------------------------------
221
+ // Properties
222
+ // ------------------------------------------------------------------
223
+ // prettier-ignore
224
+ const PropertyKey = Runtime.Union([Runtime.Ident(), Runtime.String([SingleQuote, DoubleQuote])]);
225
+ // prettier-ignore
226
+ const PropertyReadonly = Runtime.Union([Runtime.Tuple([Runtime.Const('readonly')]), Runtime.Tuple([])], value => value.length > 0);
227
+ // prettier-ignore
228
+ const PropertyOptional = Runtime.Union([Runtime.Tuple([Runtime.Const(Question)]), Runtime.Tuple([])], value => value.length > 0);
229
+ // prettier-ignore
230
+ const PropertyMapping = (Readonly, Key, Optional, _, Type) => ({
231
+ [Key]: (Readonly && Optional ? Types.ReadonlyOptional(Type) :
232
+ Readonly && !Optional ? Types.Readonly(Type) :
233
+ !Readonly && Optional ? Types.Optional(Type) :
234
+ Type)
235
+ });
236
+ // prettier-ignore
237
+ const Property = Runtime.Tuple([
238
+ Runtime.Ref('PropertyReadonly'),
239
+ Runtime.Ref('PropertyKey'),
240
+ Runtime.Ref('PropertyOptional'),
241
+ Runtime.Const(Colon),
242
+ Runtime.Ref('Type'),
243
+ ], value => PropertyMapping(...value));
244
+ // prettier-ignore
245
+ const PropertyDelimiter = Runtime.Union([
246
+ Runtime.Tuple([Runtime.Const(Comma), Runtime.Const(Newline)]),
247
+ Runtime.Tuple([Runtime.Const(SemiColon), Runtime.Const(Newline)]),
248
+ Runtime.Tuple([Runtime.Const(Comma)]),
249
+ Runtime.Tuple([Runtime.Const(SemiColon)]),
250
+ Runtime.Tuple([Runtime.Const(Newline)]),
251
+ ]);
252
+ // prettier-ignore
253
+ const Properties = Runtime.Union([
254
+ Runtime.Tuple([Runtime.Ref('Property'), Runtime.Ref('PropertyDelimiter'), Runtime.Ref('Properties')]),
255
+ Runtime.Tuple([Runtime.Ref('Property'), Runtime.Ref('PropertyDelimiter')]),
256
+ Runtime.Tuple([Runtime.Ref('Property')]),
257
+ Runtime.Tuple([])
258
+ ], values => (values.length === 3 ? [values[0], ...values[2]] :
259
+ values.length === 2 ? [values[0]] :
260
+ values.length === 1 ? [values[0]] :
261
+ []));
262
+ // ------------------------------------------------------------------
263
+ // Object
264
+ // ------------------------------------------------------------------
265
+ // prettier-ignore
266
+ const ObjectMapping = (values) => Types.Object(values.reduce((properties, record) => {
267
+ return { ...properties, ...record };
268
+ }, {}));
269
+ // prettier-ignore
270
+ const Object = Runtime.Tuple([
271
+ Runtime.Const(LBrace),
272
+ Runtime.Ref('Properties'),
273
+ Runtime.Const(RBrace)
274
+ ], values => ObjectMapping(values[1]));
275
+ // ------------------------------------------------------------------
276
+ // Tuple
277
+ // ------------------------------------------------------------------
278
+ // prettier-ignore
279
+ const Elements = Runtime.Union([
280
+ Runtime.Tuple([Runtime.Ref('Type'), Runtime.Const(Comma), Runtime.Ref('Elements')]),
281
+ Runtime.Tuple([Runtime.Ref('Type'), Runtime.Const(Comma)]),
282
+ Runtime.Tuple([Runtime.Ref('Type')]),
283
+ Runtime.Tuple([]),
284
+ ], value => (value.length === 3 ? [value[0], ...value[2]] :
285
+ value.length === 2 ? [value[0]] :
286
+ value.length === 1 ? [value[0]] :
287
+ []));
288
+ // prettier-ignore
289
+ const Tuple = Runtime.Tuple([
290
+ Runtime.Const(LBracket),
291
+ Runtime.Ref('Elements'),
292
+ Runtime.Const(RBracket)
293
+ ], value => Types.Tuple(value[1]));
294
+ // ------------------------------------------------------------------
295
+ // Parameters
296
+ // ------------------------------------------------------------------
297
+ // prettier-ignore
298
+ const Parameter = Runtime.Tuple([
299
+ Runtime.Ident(), Runtime.Const(Colon), Runtime.Ref('Type')
300
+ ], value => value[2]);
301
+ // prettier-ignore
302
+ const Parameters = Runtime.Union([
303
+ Runtime.Tuple([Runtime.Ref('Parameter'), Runtime.Const(Comma), Runtime.Ref('Parameters')]),
304
+ Runtime.Tuple([Runtime.Ref('Parameter'), Runtime.Const(Comma)]),
305
+ Runtime.Tuple([Runtime.Ref('Parameter')]),
306
+ Runtime.Tuple([]),
307
+ ], value => (value.length === 3 ? [value[0], ...value[2]] :
308
+ value.length === 2 ? [value[0]] :
309
+ value.length === 1 ? [value[0]] :
310
+ []));
311
+ // ------------------------------------------------------------------
312
+ // Constructor
313
+ // ------------------------------------------------------------------
314
+ // prettier-ignore
315
+ const Constructor = Runtime.Tuple([
316
+ Runtime.Const('new'),
317
+ Runtime.Const(LParen),
318
+ Runtime.Ref('Parameters'),
319
+ Runtime.Const(RParen),
320
+ Runtime.Const('=>'),
321
+ Runtime.Ref('Type')
322
+ ], value => Types.Constructor(value[2], value[5]));
323
+ // ------------------------------------------------------------------
324
+ // Function
325
+ // ------------------------------------------------------------------
326
+ // prettier-ignore
327
+ const Function = Runtime.Tuple([
328
+ Runtime.Const(LParen),
329
+ Runtime.Ref('Parameters'),
330
+ Runtime.Const(RParen),
331
+ Runtime.Const('=>'),
332
+ Runtime.Ref('Type')
333
+ ], value => Types.Function(value[1], value[4]));
334
+ // ------------------------------------------------------------------
335
+ // Mapped (requires deferred types)
336
+ // ------------------------------------------------------------------
337
+ // prettier-ignore
338
+ const MappedMapping = (values) => {
339
+ return Types.Literal('Mapped types not supported');
340
+ };
341
+ // prettier-ignore
342
+ const Mapped = Runtime.Tuple([
343
+ Runtime.Const(LBrace), Runtime.Const(LBracket), Runtime.Ident(), Runtime.Const('in'), Runtime.Ref('Type'), Runtime.Const(RBracket), Runtime.Const(Colon), Runtime.Ref('Type'), Runtime.Const(RBrace)
344
+ ], MappedMapping);
345
+ // ------------------------------------------------------------------
346
+ // AsyncIterator
347
+ // ------------------------------------------------------------------
348
+ // prettier-ignore
349
+ const AsyncIterator = Runtime.Tuple([
350
+ Runtime.Const('AsyncIterator'),
351
+ Runtime.Const(LAngle),
352
+ Runtime.Ref('Type'),
353
+ Runtime.Const(RAngle),
354
+ ], value => Types.AsyncIterator(value[2]));
355
+ // ------------------------------------------------------------------
356
+ // Iterator
357
+ // ------------------------------------------------------------------
358
+ // prettier-ignore
359
+ const Iterator = Runtime.Tuple([
360
+ Runtime.Const('Iterator'),
361
+ Runtime.Const(LAngle),
362
+ Runtime.Ref('Type'),
363
+ Runtime.Const(RAngle),
364
+ ], value => Types.Iterator(value[2]));
365
+ // ------------------------------------------------------------------
366
+ // ConstructorParameters
367
+ // ------------------------------------------------------------------
368
+ // prettier-ignore
369
+ const ConstructorParameters = Runtime.Tuple([
370
+ Runtime.Const('ConstructorParameters'),
371
+ Runtime.Const(LAngle),
372
+ Runtime.Ref('Type'),
373
+ Runtime.Const(RAngle),
374
+ ], value => Types.ConstructorParameters(value[2]));
375
+ // ------------------------------------------------------------------
376
+ // Parameters
377
+ // ------------------------------------------------------------------
378
+ // prettier-ignore
379
+ const FunctionParameters = Runtime.Tuple([
380
+ Runtime.Const('Parameters'),
381
+ Runtime.Const(LAngle),
382
+ Runtime.Ref('Type'),
383
+ Runtime.Const(RAngle),
384
+ ], value => Types.Parameters(value[2]));
385
+ // ------------------------------------------------------------------
386
+ // InstanceType
387
+ // ------------------------------------------------------------------
388
+ // prettier-ignore
389
+ const InstanceType = Runtime.Tuple([
390
+ Runtime.Const('InstanceType'),
391
+ Runtime.Const(LAngle),
392
+ Runtime.Ref('Type'),
393
+ Runtime.Const(RAngle),
394
+ ], value => Types.InstanceType(value[2]));
395
+ // ------------------------------------------------------------------
396
+ // ReturnType
397
+ // ------------------------------------------------------------------
398
+ // prettier-ignore
399
+ const ReturnType = Runtime.Tuple([
400
+ Runtime.Const('ReturnType'),
401
+ Runtime.Const(LAngle),
402
+ Runtime.Ref('Type'),
403
+ Runtime.Const(RAngle),
404
+ ], value => Types.ReturnType(value[2]));
405
+ // ------------------------------------------------------------------
406
+ // Awaited
407
+ // ------------------------------------------------------------------
408
+ // prettier-ignore
409
+ const Awaited = Runtime.Tuple([
410
+ Runtime.Const('Awaited'),
411
+ Runtime.Const(LAngle),
412
+ Runtime.Ref('Type'),
413
+ Runtime.Const(RAngle),
414
+ ], value => Types.Awaited(value[2]));
415
+ // ------------------------------------------------------------------
416
+ // Array
417
+ // ------------------------------------------------------------------
418
+ // prettier-ignore
419
+ const Array = Runtime.Tuple([
420
+ Runtime.Const('Array'),
421
+ Runtime.Const(LAngle),
422
+ Runtime.Ref('Type'),
423
+ Runtime.Const(RAngle),
424
+ ], value => Types.Array(value[2]));
425
+ // ------------------------------------------------------------------
426
+ // Record
427
+ // ------------------------------------------------------------------
428
+ // prettier-ignore
429
+ const Record = Runtime.Tuple([
430
+ Runtime.Const('Record'),
431
+ Runtime.Const(LAngle),
432
+ Runtime.Ref('Type'),
433
+ Runtime.Const(Comma),
434
+ Runtime.Ref('Type'),
435
+ Runtime.Const(RAngle),
436
+ ], value => Types.Record(value[2], value[4]));
437
+ // ------------------------------------------------------------------
438
+ // Promise
439
+ // ------------------------------------------------------------------
440
+ // prettier-ignore
441
+ const Promise = Runtime.Tuple([
442
+ Runtime.Const('Promise'),
443
+ Runtime.Const(LAngle),
444
+ Runtime.Ref('Type'),
445
+ Runtime.Const(RAngle),
446
+ ], value => Types.Promise(value[2]));
447
+ // ------------------------------------------------------------------
448
+ // Partial
449
+ // ------------------------------------------------------------------
450
+ // prettier-ignore
451
+ const Partial = Runtime.Tuple([
452
+ Runtime.Const('Partial'),
453
+ Runtime.Const(LAngle),
454
+ Runtime.Ref('Type'),
455
+ Runtime.Const(RAngle),
456
+ ], value => Types.Partial(value[2]));
457
+ // ------------------------------------------------------------------
458
+ // Required
459
+ // ------------------------------------------------------------------
460
+ // prettier-ignore
461
+ const Required = Runtime.Tuple([
462
+ Runtime.Const('Required'),
463
+ Runtime.Const(LAngle),
464
+ Runtime.Ref('Type'),
465
+ Runtime.Const(RAngle),
466
+ ], value => Types.Required(value[2]));
467
+ // ------------------------------------------------------------------
468
+ // Pick
469
+ // ------------------------------------------------------------------
470
+ // prettier-ignore
471
+ const Pick = Runtime.Tuple([
472
+ Runtime.Const('Pick'),
473
+ Runtime.Const(LAngle),
474
+ Runtime.Ref('Type'),
475
+ Runtime.Const(Comma),
476
+ Runtime.Ref('Type'),
477
+ Runtime.Const(RAngle),
478
+ ], value => Types.Pick(value[2], value[4]));
479
+ // ------------------------------------------------------------------
480
+ // Omit
481
+ // ------------------------------------------------------------------
482
+ // prettier-ignore
483
+ const Omit = Runtime.Tuple([
484
+ Runtime.Const('Omit'),
485
+ Runtime.Const(LAngle),
486
+ Runtime.Ref('Type'),
487
+ Runtime.Const(Comma),
488
+ Runtime.Ref('Type'),
489
+ Runtime.Const(RAngle),
490
+ ], value => Types.Omit(value[2], value[4]));
491
+ // ------------------------------------------------------------------
492
+ // Exclude
493
+ // ------------------------------------------------------------------
494
+ // prettier-ignore
495
+ const Exclude = Runtime.Tuple([
496
+ Runtime.Const('Exclude'),
497
+ Runtime.Const(LAngle),
498
+ Runtime.Ref('Type'),
499
+ Runtime.Const(Comma),
500
+ Runtime.Ref('Type'),
501
+ Runtime.Const(RAngle),
502
+ ], value => Types.Exclude(value[2], value[4]));
503
+ // ------------------------------------------------------------------
504
+ // Extract
505
+ // ------------------------------------------------------------------
506
+ // prettier-ignore
507
+ const Extract = Runtime.Tuple([
508
+ Runtime.Const('Extract'),
509
+ Runtime.Const(LAngle),
510
+ Runtime.Ref('Type'),
511
+ Runtime.Const(Comma),
512
+ Runtime.Ref('Type'),
513
+ Runtime.Const(RAngle),
514
+ ], value => Types.Extract(value[2], value[4]));
515
+ // ------------------------------------------------------------------
516
+ // Uppercase
517
+ // ------------------------------------------------------------------
518
+ // prettier-ignore
519
+ const Uppercase = Runtime.Tuple([
520
+ Runtime.Const('Uppercase'),
521
+ Runtime.Const(LAngle),
522
+ Runtime.Ref('Type'),
523
+ Runtime.Const(RAngle),
524
+ ], value => Types.Uppercase(value[2]));
525
+ // ------------------------------------------------------------------
526
+ // Lowercase
527
+ // ------------------------------------------------------------------
528
+ // prettier-ignore
529
+ const Lowercase = Runtime.Tuple([
530
+ Runtime.Const('Lowercase'),
531
+ Runtime.Const(LAngle),
532
+ Runtime.Ref('Type'),
533
+ Runtime.Const(RAngle),
534
+ ], value => Types.Lowercase(value[2]));
535
+ // ------------------------------------------------------------------
536
+ // Capitalize
537
+ // ------------------------------------------------------------------
538
+ // prettier-ignore
539
+ const Capitalize = Runtime.Tuple([
540
+ Runtime.Const('Capitalize'),
541
+ Runtime.Const(LAngle),
542
+ Runtime.Ref('Type'),
543
+ Runtime.Const(RAngle),
544
+ ], value => Types.Capitalize(value[2]));
545
+ // ------------------------------------------------------------------
546
+ // Uncapitalize
547
+ // ------------------------------------------------------------------
548
+ // prettier-ignore
549
+ const Uncapitalize = Runtime.Tuple([
550
+ Runtime.Const('Uncapitalize'),
551
+ Runtime.Const(LAngle),
552
+ Runtime.Ref('Type'),
553
+ Runtime.Const(RAngle),
554
+ ], value => Types.Uncapitalize(value[2]));
555
+ // ------------------------------------------------------------------
556
+ // Date
557
+ // ------------------------------------------------------------------
558
+ const Date = Runtime.Const('Date', Runtime.As(Types.Date()));
559
+ // ------------------------------------------------------------------
560
+ // Uint8Array
561
+ // ------------------------------------------------------------------
562
+ const Uint8Array = Runtime.Const('Uint8Array', Runtime.As(Types.Uint8Array()));
563
+ // ------------------------------------------------------------------
564
+ // Module
565
+ // ------------------------------------------------------------------
566
+ // prettier-ignore
567
+ export const Module = new Runtime.Module({
568
+ Literal,
569
+ Keyword,
570
+ KeyOf,
571
+ IndexArray,
572
+ Extends,
573
+ Base,
574
+ Factor,
575
+ ExprTermTail,
576
+ ExprTerm,
577
+ ExprTail,
578
+ Expr,
579
+ Type,
580
+ PropertyKey,
581
+ PropertyReadonly,
582
+ PropertyOptional,
583
+ Property,
584
+ PropertyDelimiter,
585
+ Properties,
586
+ Object,
587
+ Elements,
588
+ Tuple,
589
+ Parameter,
590
+ Function,
591
+ Parameters,
592
+ Constructor,
593
+ Mapped,
594
+ AsyncIterator,
595
+ Iterator,
596
+ Awaited,
597
+ Array,
598
+ Record,
599
+ Promise,
600
+ ConstructorParameters,
601
+ FunctionParameters,
602
+ InstanceType,
603
+ ReturnType,
604
+ Partial,
605
+ Required,
606
+ Pick,
607
+ Omit,
608
+ Exclude,
609
+ Extract,
610
+ Uppercase,
611
+ Lowercase,
612
+ Capitalize,
613
+ Uncapitalize,
614
+ Date,
615
+ Uint8Array,
616
+ Reference
617
+ });