@sinclair/typebox 0.34.31 → 0.34.32
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/build/cjs/syntax/mapping.d.ts +167 -0
- package/build/cjs/syntax/mapping.js +458 -0
- package/build/cjs/syntax/parser.d.ts +162 -0
- package/build/cjs/syntax/parser.js +158 -0
- package/build/cjs/syntax/syntax.d.ts +12 -29
- package/build/cjs/syntax/syntax.js +5 -19
- package/build/esm/syntax/mapping.d.mts +167 -0
- package/build/esm/syntax/mapping.mjs +386 -0
- package/build/esm/syntax/parser.d.mts +162 -0
- package/build/esm/syntax/parser.mjs +78 -0
- package/build/esm/syntax/syntax.d.mts +12 -29
- package/build/esm/syntax/syntax.mjs +5 -17
- package/package.json +1 -1
- package/build/cjs/syntax/runtime.d.ts +0 -60
- package/build/cjs/syntax/runtime.js +0 -715
- package/build/cjs/syntax/static.d.ts +0 -484
- package/build/cjs/syntax/static.js +0 -3
- package/build/esm/syntax/runtime.d.mts +0 -60
- package/build/esm/syntax/runtime.mjs +0 -711
- package/build/esm/syntax/static.d.mts +0 -484
- package/build/esm/syntax/static.mjs +0 -1
|
@@ -1,711 +0,0 @@
|
|
|
1
|
-
import { Runtime } from '../parser/index.mjs';
|
|
2
|
-
import * as t 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
|
-
const Equals = '=';
|
|
23
|
-
// ------------------------------------------------------------------
|
|
24
|
-
// DestructureRight
|
|
25
|
-
// ------------------------------------------------------------------
|
|
26
|
-
// prettier-ignore
|
|
27
|
-
function DestructureRight(values) {
|
|
28
|
-
return (values.length > 0)
|
|
29
|
-
? [values.slice(0, values.length - 1), values[values.length - 1]]
|
|
30
|
-
: [values, undefined];
|
|
31
|
-
}
|
|
32
|
-
// ------------------------------------------------------------------
|
|
33
|
-
// Delimit
|
|
34
|
-
// ------------------------------------------------------------------
|
|
35
|
-
// prettier-ignore
|
|
36
|
-
const DelimitHeadMapping = (results) => results.reduce((result, value) => {
|
|
37
|
-
const [element, _delimiter] = value;
|
|
38
|
-
return [...result, element];
|
|
39
|
-
}, []);
|
|
40
|
-
// prettier-ignore
|
|
41
|
-
const DelimitHead = (element, delimiter) => (Runtime.Array(Runtime.Tuple([element, delimiter]), DelimitHeadMapping));
|
|
42
|
-
// prettier-ignore
|
|
43
|
-
const DelimitTail = (element) => Runtime.Union([
|
|
44
|
-
Runtime.Tuple([element]),
|
|
45
|
-
Runtime.Tuple([]),
|
|
46
|
-
]);
|
|
47
|
-
// prettier-ignore
|
|
48
|
-
const DelimitMapping = (results) => {
|
|
49
|
-
return [...results[0], ...results[1]];
|
|
50
|
-
};
|
|
51
|
-
// prettier-ignore
|
|
52
|
-
const Delimit = (element, delimiter) => Runtime.Tuple([
|
|
53
|
-
DelimitHead(element, delimiter),
|
|
54
|
-
DelimitTail(element),
|
|
55
|
-
], DelimitMapping);
|
|
56
|
-
// ------------------------------------------------------------------
|
|
57
|
-
// Dereference
|
|
58
|
-
// ------------------------------------------------------------------
|
|
59
|
-
const Dereference = (context, key) => {
|
|
60
|
-
return key in context ? context[key] : t.Ref(key);
|
|
61
|
-
};
|
|
62
|
-
// ------------------------------------------------------------------
|
|
63
|
-
// GenericArgumentsList
|
|
64
|
-
// ------------------------------------------------------------------
|
|
65
|
-
// prettier-ignore
|
|
66
|
-
const GenericArgumentsList = Delimit(Runtime.Ident(), Runtime.Const(Comma));
|
|
67
|
-
// ------------------------------------------------------------------
|
|
68
|
-
// GenericArguments
|
|
69
|
-
// ------------------------------------------------------------------
|
|
70
|
-
// prettier-ignore
|
|
71
|
-
const GenericArgumentsContext = (args, context) => {
|
|
72
|
-
return args.reduce((result, arg, index) => {
|
|
73
|
-
return { ...result, [arg]: t.Argument(index) };
|
|
74
|
-
}, context);
|
|
75
|
-
};
|
|
76
|
-
// prettier-ignore
|
|
77
|
-
const GenericArgumentsMapping = (results, context) => {
|
|
78
|
-
return results.length === 3
|
|
79
|
-
? GenericArgumentsContext(results[1], context)
|
|
80
|
-
: {};
|
|
81
|
-
};
|
|
82
|
-
// prettier-ignore
|
|
83
|
-
const GenericArguments = Runtime.Tuple([
|
|
84
|
-
Runtime.Const(LAngle),
|
|
85
|
-
Runtime.Ref('GenericArgumentsList'),
|
|
86
|
-
Runtime.Const(RAngle),
|
|
87
|
-
], (results, context) => GenericArgumentsMapping(results, context));
|
|
88
|
-
// ------------------------------------------------------------------
|
|
89
|
-
// GenericReference
|
|
90
|
-
// ------------------------------------------------------------------
|
|
91
|
-
function GenericReferenceMapping(results, context) {
|
|
92
|
-
const type = Dereference(context, results[0]);
|
|
93
|
-
const args = results[2];
|
|
94
|
-
return t.Instantiate(type, args);
|
|
95
|
-
}
|
|
96
|
-
const GenericReferenceParameters = Delimit(Runtime.Ref('Type'), Runtime.Const(Comma));
|
|
97
|
-
// prettier-ignore
|
|
98
|
-
const GenericReference = Runtime.Tuple([
|
|
99
|
-
Runtime.Ident(),
|
|
100
|
-
Runtime.Const(LAngle),
|
|
101
|
-
Runtime.Ref('GenericReferenceParameters'),
|
|
102
|
-
Runtime.Const(RAngle)
|
|
103
|
-
], (results, context) => GenericReferenceMapping(results, context));
|
|
104
|
-
// ------------------------------------------------------------------
|
|
105
|
-
// Reference
|
|
106
|
-
// ------------------------------------------------------------------
|
|
107
|
-
function ReferenceMapping(result, context) {
|
|
108
|
-
const target = Dereference(context, result);
|
|
109
|
-
return target;
|
|
110
|
-
}
|
|
111
|
-
// prettier-ignore
|
|
112
|
-
const Reference = Runtime.Ident((result, context) => ReferenceMapping(result, context));
|
|
113
|
-
// ------------------------------------------------------------------
|
|
114
|
-
// Literal
|
|
115
|
-
// ------------------------------------------------------------------
|
|
116
|
-
// prettier-ignore
|
|
117
|
-
const Literal = Runtime.Union([
|
|
118
|
-
Runtime.Union([Runtime.Const('true'), Runtime.Const('false')], value => t.Literal(value === 'true')),
|
|
119
|
-
Runtime.Number(value => t.Literal(parseFloat(value))),
|
|
120
|
-
Runtime.String([SingleQuote, DoubleQuote, Tilde], value => t.Literal(value))
|
|
121
|
-
]);
|
|
122
|
-
// ------------------------------------------------------------------
|
|
123
|
-
// Keyword
|
|
124
|
-
// ------------------------------------------------------------------
|
|
125
|
-
// prettier-ignore
|
|
126
|
-
const Keyword = Runtime.Union([
|
|
127
|
-
Runtime.Const('string', Runtime.As(t.String())),
|
|
128
|
-
Runtime.Const('number', Runtime.As(t.Number())),
|
|
129
|
-
Runtime.Const('boolean', Runtime.As(t.Boolean())),
|
|
130
|
-
Runtime.Const('undefined', Runtime.As(t.Undefined())),
|
|
131
|
-
Runtime.Const('null', Runtime.As(t.Null())),
|
|
132
|
-
Runtime.Const('integer', Runtime.As(t.Integer())),
|
|
133
|
-
Runtime.Const('bigint', Runtime.As(t.BigInt())),
|
|
134
|
-
Runtime.Const('unknown', Runtime.As(t.Unknown())),
|
|
135
|
-
Runtime.Const('any', Runtime.As(t.Any())),
|
|
136
|
-
Runtime.Const('never', Runtime.As(t.Never())),
|
|
137
|
-
Runtime.Const('symbol', Runtime.As(t.Symbol())),
|
|
138
|
-
Runtime.Const('void', Runtime.As(t.Void())),
|
|
139
|
-
]);
|
|
140
|
-
// ------------------------------------------------------------------
|
|
141
|
-
// KeyOf
|
|
142
|
-
// ------------------------------------------------------------------
|
|
143
|
-
// prettier-ignore
|
|
144
|
-
const KeyOfMapping = (values) => (values.length > 0);
|
|
145
|
-
// prettier-ignore
|
|
146
|
-
const KeyOf = Runtime.Union([
|
|
147
|
-
Runtime.Tuple([Runtime.Const('keyof')]), Runtime.Tuple([])
|
|
148
|
-
], KeyOfMapping);
|
|
149
|
-
// ------------------------------------------------------------------
|
|
150
|
-
// IndexArray
|
|
151
|
-
// ------------------------------------------------------------------
|
|
152
|
-
// prettier-ignore
|
|
153
|
-
const IndexArrayMapping = (results) => {
|
|
154
|
-
return results.reduce((result, current) => {
|
|
155
|
-
return current.length === 3
|
|
156
|
-
? [...result, [current[1]]]
|
|
157
|
-
: [...result, []];
|
|
158
|
-
}, []);
|
|
159
|
-
};
|
|
160
|
-
// prettier-ignore
|
|
161
|
-
const IndexArray = Runtime.Array(Runtime.Union([
|
|
162
|
-
Runtime.Tuple([Runtime.Const(LBracket), Runtime.Ref('Type'), Runtime.Const(RBracket)]),
|
|
163
|
-
Runtime.Tuple([Runtime.Const(LBracket), Runtime.Const(RBracket)]),
|
|
164
|
-
]), IndexArrayMapping);
|
|
165
|
-
// ------------------------------------------------------------------
|
|
166
|
-
// Extends
|
|
167
|
-
// ------------------------------------------------------------------
|
|
168
|
-
// prettier-ignore
|
|
169
|
-
const ExtendsMapping = (values) => {
|
|
170
|
-
return values.length === 6
|
|
171
|
-
? [values[1], values[3], values[5]]
|
|
172
|
-
: [];
|
|
173
|
-
};
|
|
174
|
-
// prettier-ignore
|
|
175
|
-
const Extends = Runtime.Union([
|
|
176
|
-
Runtime.Tuple([Runtime.Const('extends'), Runtime.Ref('Type'), Runtime.Const(Question), Runtime.Ref('Type'), Runtime.Const(Colon), Runtime.Ref('Type')]),
|
|
177
|
-
Runtime.Tuple([])
|
|
178
|
-
], ExtendsMapping);
|
|
179
|
-
// ------------------------------------------------------------------
|
|
180
|
-
// Base
|
|
181
|
-
// ------------------------------------------------------------------
|
|
182
|
-
// prettier-ignore
|
|
183
|
-
const BaseMapping = (value) => {
|
|
184
|
-
return t.ValueGuard.IsArray(value) && value.length === 3
|
|
185
|
-
? value[1]
|
|
186
|
-
: value;
|
|
187
|
-
};
|
|
188
|
-
// prettier-ignore
|
|
189
|
-
const Base = Runtime.Union([
|
|
190
|
-
Runtime.Tuple([Runtime.Const(LParen), Runtime.Ref('Type'), Runtime.Const(RParen)]),
|
|
191
|
-
Runtime.Ref('Keyword'),
|
|
192
|
-
Runtime.Ref('Object'),
|
|
193
|
-
Runtime.Ref('Tuple'),
|
|
194
|
-
Runtime.Ref('Literal'),
|
|
195
|
-
Runtime.Ref('Constructor'),
|
|
196
|
-
Runtime.Ref('Function'),
|
|
197
|
-
Runtime.Ref('Mapped'),
|
|
198
|
-
Runtime.Ref('AsyncIterator'),
|
|
199
|
-
Runtime.Ref('Iterator'),
|
|
200
|
-
Runtime.Ref('ConstructorParameters'),
|
|
201
|
-
Runtime.Ref('FunctionParameters'),
|
|
202
|
-
Runtime.Ref('InstanceType'),
|
|
203
|
-
Runtime.Ref('ReturnType'),
|
|
204
|
-
Runtime.Ref('Argument'),
|
|
205
|
-
Runtime.Ref('Awaited'),
|
|
206
|
-
Runtime.Ref('Array'),
|
|
207
|
-
Runtime.Ref('Record'),
|
|
208
|
-
Runtime.Ref('Promise'),
|
|
209
|
-
Runtime.Ref('Partial'),
|
|
210
|
-
Runtime.Ref('Required'),
|
|
211
|
-
Runtime.Ref('Pick'),
|
|
212
|
-
Runtime.Ref('Omit'),
|
|
213
|
-
Runtime.Ref('Exclude'),
|
|
214
|
-
Runtime.Ref('Extract'),
|
|
215
|
-
Runtime.Ref('Uppercase'),
|
|
216
|
-
Runtime.Ref('Lowercase'),
|
|
217
|
-
Runtime.Ref('Capitalize'),
|
|
218
|
-
Runtime.Ref('Uncapitalize'),
|
|
219
|
-
Runtime.Ref('Date'),
|
|
220
|
-
Runtime.Ref('Uint8Array'),
|
|
221
|
-
Runtime.Ref('GenericReference'),
|
|
222
|
-
Runtime.Ref('Reference')
|
|
223
|
-
], BaseMapping);
|
|
224
|
-
// ------------------------------------------------------------------
|
|
225
|
-
// Factor
|
|
226
|
-
// ------------------------------------------------------------------
|
|
227
|
-
// prettier-ignore
|
|
228
|
-
const FactorExtends = (Type, Extends) => {
|
|
229
|
-
return Extends.length === 3
|
|
230
|
-
? t.Extends(Type, Extends[0], Extends[1], Extends[2])
|
|
231
|
-
: Type;
|
|
232
|
-
};
|
|
233
|
-
// prettier-ignore
|
|
234
|
-
const FactorIndexArray = (Type, IndexArray) => {
|
|
235
|
-
const [Left, Right] = DestructureRight(IndexArray);
|
|
236
|
-
return (!t.ValueGuard.IsUndefined(Right) ? (
|
|
237
|
-
// note: Indexed types require reimplementation to replace `[number]` indexers
|
|
238
|
-
Right.length === 1 ? t.Index(FactorIndexArray(Type, Left), Right[0]) :
|
|
239
|
-
Right.length === 0 ? t.Array(FactorIndexArray(Type, Left)) :
|
|
240
|
-
t.Never()) : Type);
|
|
241
|
-
};
|
|
242
|
-
// prettier-ignore
|
|
243
|
-
const FactorMapping = (KeyOf, Type, IndexArray, Extends) => {
|
|
244
|
-
return KeyOf
|
|
245
|
-
? FactorExtends(t.KeyOf(FactorIndexArray(Type, IndexArray)), Extends)
|
|
246
|
-
: FactorExtends(FactorIndexArray(Type, IndexArray), Extends);
|
|
247
|
-
};
|
|
248
|
-
// prettier-ignore
|
|
249
|
-
const Factor = Runtime.Tuple([
|
|
250
|
-
Runtime.Ref('KeyOf'),
|
|
251
|
-
Runtime.Ref('Base'),
|
|
252
|
-
Runtime.Ref('IndexArray'),
|
|
253
|
-
Runtime.Ref('Extends')
|
|
254
|
-
], results => FactorMapping(...results));
|
|
255
|
-
// ------------------------------------------------------------------
|
|
256
|
-
// Expr
|
|
257
|
-
// ------------------------------------------------------------------
|
|
258
|
-
// prettier-ignore
|
|
259
|
-
function ExprBinaryMapping(Left, Rest) {
|
|
260
|
-
return (Rest.length === 3 ? (() => {
|
|
261
|
-
const [Operator, Right, Next] = Rest;
|
|
262
|
-
const Schema = ExprBinaryMapping(Right, Next);
|
|
263
|
-
if (Operator === '&') {
|
|
264
|
-
return t.TypeGuard.IsIntersect(Schema)
|
|
265
|
-
? t.Intersect([Left, ...Schema.allOf])
|
|
266
|
-
: t.Intersect([Left, Schema]);
|
|
267
|
-
}
|
|
268
|
-
if (Operator === '|') {
|
|
269
|
-
return t.TypeGuard.IsUnion(Schema)
|
|
270
|
-
? t.Union([Left, ...Schema.anyOf])
|
|
271
|
-
: t.Union([Left, Schema]);
|
|
272
|
-
}
|
|
273
|
-
throw 1;
|
|
274
|
-
})() : Left);
|
|
275
|
-
}
|
|
276
|
-
// prettier-ignore
|
|
277
|
-
const ExprTermTail = Runtime.Union([
|
|
278
|
-
Runtime.Tuple([Runtime.Const('&'), Runtime.Ref('Factor'), Runtime.Ref('ExprTermTail')]),
|
|
279
|
-
Runtime.Tuple([])
|
|
280
|
-
]);
|
|
281
|
-
// prettier-ignore
|
|
282
|
-
const ExprTerm = Runtime.Tuple([
|
|
283
|
-
Runtime.Ref('Factor'), Runtime.Ref('ExprTermTail')
|
|
284
|
-
], results => ExprBinaryMapping(...results));
|
|
285
|
-
// prettier-ignore
|
|
286
|
-
const ExprTail = Runtime.Union([
|
|
287
|
-
Runtime.Tuple([Runtime.Const('|'), Runtime.Ref('ExprTerm'), Runtime.Ref('ExprTail')]),
|
|
288
|
-
Runtime.Tuple([])
|
|
289
|
-
]);
|
|
290
|
-
// prettier-ignore
|
|
291
|
-
const Expr = Runtime.Tuple([
|
|
292
|
-
Runtime.Ref('ExprTerm'), Runtime.Ref('ExprTail')
|
|
293
|
-
], results => ExprBinaryMapping(...results));
|
|
294
|
-
// ------------------------------------------------------------------
|
|
295
|
-
// Type
|
|
296
|
-
// ------------------------------------------------------------------
|
|
297
|
-
// prettier-ignore
|
|
298
|
-
const Type = Runtime.Union([
|
|
299
|
-
Runtime.Context(Runtime.Ref('GenericArguments'), Runtime.Ref('Expr')),
|
|
300
|
-
Runtime.Ref('Expr')
|
|
301
|
-
]);
|
|
302
|
-
// ------------------------------------------------------------------
|
|
303
|
-
// Property
|
|
304
|
-
// ------------------------------------------------------------------
|
|
305
|
-
const PropertyKey = Runtime.Union([Runtime.Ident(), Runtime.String([SingleQuote, DoubleQuote])]);
|
|
306
|
-
const Readonly = Runtime.Union([Runtime.Tuple([Runtime.Const('readonly')]), Runtime.Tuple([])], (value) => value.length > 0);
|
|
307
|
-
const Optional = Runtime.Union([Runtime.Tuple([Runtime.Const(Question)]), Runtime.Tuple([])], (value) => value.length > 0);
|
|
308
|
-
// prettier-ignore
|
|
309
|
-
const PropertyMapping = (IsReadonly, Key, IsOptional, _, Type) => ({
|
|
310
|
-
[Key]: (IsReadonly && IsOptional ? t.ReadonlyOptional(Type) :
|
|
311
|
-
IsReadonly && !IsOptional ? t.Readonly(Type) :
|
|
312
|
-
!IsReadonly && IsOptional ? t.Optional(Type) :
|
|
313
|
-
Type)
|
|
314
|
-
});
|
|
315
|
-
// prettier-ignore
|
|
316
|
-
const Property = Runtime.Tuple([
|
|
317
|
-
Runtime.Ref('Readonly'),
|
|
318
|
-
Runtime.Ref('PropertyKey'),
|
|
319
|
-
Runtime.Ref('Optional'),
|
|
320
|
-
Runtime.Const(Colon),
|
|
321
|
-
Runtime.Ref('Type'),
|
|
322
|
-
], results => PropertyMapping(...results));
|
|
323
|
-
// ------------------------------------------------------------------
|
|
324
|
-
// PropertyDelimiter
|
|
325
|
-
// ------------------------------------------------------------------
|
|
326
|
-
// prettier-ignore
|
|
327
|
-
const PropertyDelimiter = Runtime.Union([
|
|
328
|
-
Runtime.Tuple([Runtime.Const(Comma), Runtime.Const(Newline)]),
|
|
329
|
-
Runtime.Tuple([Runtime.Const(SemiColon), Runtime.Const(Newline)]),
|
|
330
|
-
Runtime.Tuple([Runtime.Const(Comma)]),
|
|
331
|
-
Runtime.Tuple([Runtime.Const(SemiColon)]),
|
|
332
|
-
Runtime.Tuple([Runtime.Const(Newline)]),
|
|
333
|
-
]);
|
|
334
|
-
// ------------------------------------------------------------------
|
|
335
|
-
// PropertyList
|
|
336
|
-
// ------------------------------------------------------------------
|
|
337
|
-
const PropertyList = Delimit(Runtime.Ref('Property'), Runtime.Ref('PropertyDelimiter'));
|
|
338
|
-
// ------------------------------------------------------------------
|
|
339
|
-
// Object
|
|
340
|
-
// ------------------------------------------------------------------
|
|
341
|
-
// prettier-ignore
|
|
342
|
-
const ObjectMapping = (results) => {
|
|
343
|
-
const propertyList = results[1];
|
|
344
|
-
return t.Object(propertyList.reduce((result, property) => {
|
|
345
|
-
return { ...result, ...property };
|
|
346
|
-
}, {}));
|
|
347
|
-
};
|
|
348
|
-
// prettier-ignore
|
|
349
|
-
const _Object = Runtime.Tuple([
|
|
350
|
-
Runtime.Const(LBrace),
|
|
351
|
-
Runtime.Ref('PropertyList'),
|
|
352
|
-
Runtime.Const(RBrace)
|
|
353
|
-
], ObjectMapping);
|
|
354
|
-
// ------------------------------------------------------------------
|
|
355
|
-
// ElementList
|
|
356
|
-
// ------------------------------------------------------------------
|
|
357
|
-
const ElementList = Delimit(Runtime.Ref('Type'), Runtime.Const(Comma));
|
|
358
|
-
// ------------------------------------------------------------------
|
|
359
|
-
// Tuple
|
|
360
|
-
// ------------------------------------------------------------------
|
|
361
|
-
// prettier-ignore
|
|
362
|
-
const Tuple = Runtime.Tuple([
|
|
363
|
-
Runtime.Const(LBracket),
|
|
364
|
-
Runtime.Ref('ElementList'),
|
|
365
|
-
Runtime.Const(RBracket)
|
|
366
|
-
], results => t.Tuple(results[1]));
|
|
367
|
-
// ------------------------------------------------------------------
|
|
368
|
-
// Parameters
|
|
369
|
-
// ------------------------------------------------------------------
|
|
370
|
-
// prettier-ignore
|
|
371
|
-
const Parameter = Runtime.Tuple([
|
|
372
|
-
Runtime.Ident(), Runtime.Const(Colon), Runtime.Ref('Type')
|
|
373
|
-
], results => results[2]);
|
|
374
|
-
// ------------------------------------------------------------------
|
|
375
|
-
// ParameterList
|
|
376
|
-
// ------------------------------------------------------------------
|
|
377
|
-
const ParameterList = Delimit(Runtime.Ref('Parameter'), Runtime.Const(Comma));
|
|
378
|
-
// ------------------------------------------------------------------
|
|
379
|
-
// Constructor
|
|
380
|
-
// ------------------------------------------------------------------
|
|
381
|
-
// prettier-ignore
|
|
382
|
-
const Constructor = Runtime.Tuple([
|
|
383
|
-
Runtime.Const('new'),
|
|
384
|
-
Runtime.Const(LParen),
|
|
385
|
-
Runtime.Ref('ParameterList'),
|
|
386
|
-
Runtime.Const(RParen),
|
|
387
|
-
Runtime.Const('=>'),
|
|
388
|
-
Runtime.Ref('Type')
|
|
389
|
-
], results => t.Constructor(results[2], results[5]));
|
|
390
|
-
// ------------------------------------------------------------------
|
|
391
|
-
// Function
|
|
392
|
-
// ------------------------------------------------------------------
|
|
393
|
-
// prettier-ignore
|
|
394
|
-
const Function = Runtime.Tuple([
|
|
395
|
-
Runtime.Const(LParen),
|
|
396
|
-
Runtime.Ref('ParameterList'),
|
|
397
|
-
Runtime.Const(RParen),
|
|
398
|
-
Runtime.Const('=>'),
|
|
399
|
-
Runtime.Ref('Type')
|
|
400
|
-
], results => t.Function(results[1], results[4]));
|
|
401
|
-
// ------------------------------------------------------------------
|
|
402
|
-
// Mapped (requires deferred types)
|
|
403
|
-
// ------------------------------------------------------------------
|
|
404
|
-
// prettier-ignore
|
|
405
|
-
const MappedMapping = (results) => {
|
|
406
|
-
return t.Literal('Mapped types not supported');
|
|
407
|
-
};
|
|
408
|
-
// prettier-ignore
|
|
409
|
-
const Mapped = Runtime.Tuple([
|
|
410
|
-
Runtime.Const(LBrace),
|
|
411
|
-
Runtime.Const(LBracket),
|
|
412
|
-
Runtime.Ident(),
|
|
413
|
-
Runtime.Const('in'),
|
|
414
|
-
Runtime.Ref('Type'),
|
|
415
|
-
Runtime.Const(RBracket),
|
|
416
|
-
Runtime.Const(Colon),
|
|
417
|
-
Runtime.Ref('Type'),
|
|
418
|
-
Runtime.Const(RBrace)
|
|
419
|
-
], MappedMapping);
|
|
420
|
-
// ------------------------------------------------------------------
|
|
421
|
-
// AsyncIterator
|
|
422
|
-
// ------------------------------------------------------------------
|
|
423
|
-
// prettier-ignore
|
|
424
|
-
const AsyncIterator = Runtime.Tuple([
|
|
425
|
-
Runtime.Const('AsyncIterator'),
|
|
426
|
-
Runtime.Const(LAngle),
|
|
427
|
-
Runtime.Ref('Type'),
|
|
428
|
-
Runtime.Const(RAngle),
|
|
429
|
-
], results => t.AsyncIterator(results[2]));
|
|
430
|
-
// ------------------------------------------------------------------
|
|
431
|
-
// Iterator
|
|
432
|
-
// ------------------------------------------------------------------
|
|
433
|
-
// prettier-ignore
|
|
434
|
-
const Iterator = Runtime.Tuple([
|
|
435
|
-
Runtime.Const('Iterator'),
|
|
436
|
-
Runtime.Const(LAngle),
|
|
437
|
-
Runtime.Ref('Type'),
|
|
438
|
-
Runtime.Const(RAngle),
|
|
439
|
-
], results => t.Iterator(results[2]));
|
|
440
|
-
// ------------------------------------------------------------------
|
|
441
|
-
// ConstructorParameters
|
|
442
|
-
// ------------------------------------------------------------------
|
|
443
|
-
// prettier-ignore
|
|
444
|
-
const ConstructorParameters = Runtime.Tuple([
|
|
445
|
-
Runtime.Const('ConstructorParameters'),
|
|
446
|
-
Runtime.Const(LAngle),
|
|
447
|
-
Runtime.Ref('Type'),
|
|
448
|
-
Runtime.Const(RAngle),
|
|
449
|
-
], results => t.ConstructorParameters(results[2]));
|
|
450
|
-
// ------------------------------------------------------------------
|
|
451
|
-
// Parameters
|
|
452
|
-
// ------------------------------------------------------------------
|
|
453
|
-
// prettier-ignore
|
|
454
|
-
const FunctionParameters = Runtime.Tuple([
|
|
455
|
-
Runtime.Const('Parameters'),
|
|
456
|
-
Runtime.Const(LAngle),
|
|
457
|
-
Runtime.Ref('Type'),
|
|
458
|
-
Runtime.Const(RAngle),
|
|
459
|
-
], results => t.Parameters(results[2]));
|
|
460
|
-
// ------------------------------------------------------------------
|
|
461
|
-
// InstanceType
|
|
462
|
-
// ------------------------------------------------------------------
|
|
463
|
-
// prettier-ignore
|
|
464
|
-
const InstanceType = Runtime.Tuple([
|
|
465
|
-
Runtime.Const('InstanceType'),
|
|
466
|
-
Runtime.Const(LAngle),
|
|
467
|
-
Runtime.Ref('Type'),
|
|
468
|
-
Runtime.Const(RAngle),
|
|
469
|
-
], results => t.InstanceType(results[2]));
|
|
470
|
-
// ------------------------------------------------------------------
|
|
471
|
-
// ReturnType
|
|
472
|
-
// ------------------------------------------------------------------
|
|
473
|
-
// prettier-ignore
|
|
474
|
-
const ReturnType = Runtime.Tuple([
|
|
475
|
-
Runtime.Const('ReturnType'),
|
|
476
|
-
Runtime.Const(LAngle),
|
|
477
|
-
Runtime.Ref('Type'),
|
|
478
|
-
Runtime.Const(RAngle),
|
|
479
|
-
], results => t.ReturnType(results[2]));
|
|
480
|
-
// ------------------------------------------------------------------
|
|
481
|
-
// Argument
|
|
482
|
-
// ------------------------------------------------------------------
|
|
483
|
-
// prettier-ignore
|
|
484
|
-
const Argument = Runtime.Tuple([
|
|
485
|
-
Runtime.Const('Argument'),
|
|
486
|
-
Runtime.Const(LAngle),
|
|
487
|
-
Runtime.Ref('Type'),
|
|
488
|
-
Runtime.Const(RAngle),
|
|
489
|
-
], results => {
|
|
490
|
-
return t.KindGuard.IsLiteralNumber(results[2])
|
|
491
|
-
? t.Argument(Math.trunc(results[2].const))
|
|
492
|
-
: t.Never();
|
|
493
|
-
});
|
|
494
|
-
// ------------------------------------------------------------------
|
|
495
|
-
// Awaited
|
|
496
|
-
// ------------------------------------------------------------------
|
|
497
|
-
// prettier-ignore
|
|
498
|
-
const Awaited = Runtime.Tuple([
|
|
499
|
-
Runtime.Const('Awaited'),
|
|
500
|
-
Runtime.Const(LAngle),
|
|
501
|
-
Runtime.Ref('Type'),
|
|
502
|
-
Runtime.Const(RAngle),
|
|
503
|
-
], results => t.Awaited(results[2]));
|
|
504
|
-
// ------------------------------------------------------------------
|
|
505
|
-
// Array
|
|
506
|
-
// ------------------------------------------------------------------
|
|
507
|
-
// prettier-ignore
|
|
508
|
-
const Array = Runtime.Tuple([
|
|
509
|
-
Runtime.Const('Array'),
|
|
510
|
-
Runtime.Const(LAngle),
|
|
511
|
-
Runtime.Ref('Type'),
|
|
512
|
-
Runtime.Const(RAngle),
|
|
513
|
-
], results => t.Array(results[2]));
|
|
514
|
-
// ------------------------------------------------------------------
|
|
515
|
-
// Record
|
|
516
|
-
// ------------------------------------------------------------------
|
|
517
|
-
// prettier-ignore
|
|
518
|
-
const Record = Runtime.Tuple([
|
|
519
|
-
Runtime.Const('Record'),
|
|
520
|
-
Runtime.Const(LAngle),
|
|
521
|
-
Runtime.Ref('Type'),
|
|
522
|
-
Runtime.Const(Comma),
|
|
523
|
-
Runtime.Ref('Type'),
|
|
524
|
-
Runtime.Const(RAngle),
|
|
525
|
-
], results => t.Record(results[2], results[4]));
|
|
526
|
-
// ------------------------------------------------------------------
|
|
527
|
-
// Promise
|
|
528
|
-
// ------------------------------------------------------------------
|
|
529
|
-
// prettier-ignore
|
|
530
|
-
const Promise = Runtime.Tuple([
|
|
531
|
-
Runtime.Const('Promise'),
|
|
532
|
-
Runtime.Const(LAngle),
|
|
533
|
-
Runtime.Ref('Type'),
|
|
534
|
-
Runtime.Const(RAngle),
|
|
535
|
-
], results => t.Promise(results[2]));
|
|
536
|
-
// ------------------------------------------------------------------
|
|
537
|
-
// Partial
|
|
538
|
-
// ------------------------------------------------------------------
|
|
539
|
-
// prettier-ignore
|
|
540
|
-
const Partial = Runtime.Tuple([
|
|
541
|
-
Runtime.Const('Partial'),
|
|
542
|
-
Runtime.Const(LAngle),
|
|
543
|
-
Runtime.Ref('Type'),
|
|
544
|
-
Runtime.Const(RAngle),
|
|
545
|
-
], results => t.Partial(results[2]));
|
|
546
|
-
// ------------------------------------------------------------------
|
|
547
|
-
// Required
|
|
548
|
-
// ------------------------------------------------------------------
|
|
549
|
-
// prettier-ignore
|
|
550
|
-
const Required = Runtime.Tuple([
|
|
551
|
-
Runtime.Const('Required'),
|
|
552
|
-
Runtime.Const(LAngle),
|
|
553
|
-
Runtime.Ref('Type'),
|
|
554
|
-
Runtime.Const(RAngle),
|
|
555
|
-
], results => t.Required(results[2]));
|
|
556
|
-
// ------------------------------------------------------------------
|
|
557
|
-
// Pick
|
|
558
|
-
// ------------------------------------------------------------------
|
|
559
|
-
// prettier-ignore
|
|
560
|
-
const Pick = Runtime.Tuple([
|
|
561
|
-
Runtime.Const('Pick'),
|
|
562
|
-
Runtime.Const(LAngle),
|
|
563
|
-
Runtime.Ref('Type'),
|
|
564
|
-
Runtime.Const(Comma),
|
|
565
|
-
Runtime.Ref('Type'),
|
|
566
|
-
Runtime.Const(RAngle),
|
|
567
|
-
], results => t.Pick(results[2], results[4]));
|
|
568
|
-
// ------------------------------------------------------------------
|
|
569
|
-
// Omit
|
|
570
|
-
// ------------------------------------------------------------------
|
|
571
|
-
// prettier-ignore
|
|
572
|
-
const Omit = Runtime.Tuple([
|
|
573
|
-
Runtime.Const('Omit'),
|
|
574
|
-
Runtime.Const(LAngle),
|
|
575
|
-
Runtime.Ref('Type'),
|
|
576
|
-
Runtime.Const(Comma),
|
|
577
|
-
Runtime.Ref('Type'),
|
|
578
|
-
Runtime.Const(RAngle),
|
|
579
|
-
], results => t.Omit(results[2], results[4]));
|
|
580
|
-
// ------------------------------------------------------------------
|
|
581
|
-
// Exclude
|
|
582
|
-
// ------------------------------------------------------------------
|
|
583
|
-
// prettier-ignore
|
|
584
|
-
const Exclude = Runtime.Tuple([
|
|
585
|
-
Runtime.Const('Exclude'),
|
|
586
|
-
Runtime.Const(LAngle),
|
|
587
|
-
Runtime.Ref('Type'),
|
|
588
|
-
Runtime.Const(Comma),
|
|
589
|
-
Runtime.Ref('Type'),
|
|
590
|
-
Runtime.Const(RAngle),
|
|
591
|
-
], results => t.Exclude(results[2], results[4]));
|
|
592
|
-
// ------------------------------------------------------------------
|
|
593
|
-
// Extract
|
|
594
|
-
// ------------------------------------------------------------------
|
|
595
|
-
// prettier-ignore
|
|
596
|
-
const Extract = Runtime.Tuple([
|
|
597
|
-
Runtime.Const('Extract'),
|
|
598
|
-
Runtime.Const(LAngle),
|
|
599
|
-
Runtime.Ref('Type'),
|
|
600
|
-
Runtime.Const(Comma),
|
|
601
|
-
Runtime.Ref('Type'),
|
|
602
|
-
Runtime.Const(RAngle),
|
|
603
|
-
], results => t.Extract(results[2], results[4]));
|
|
604
|
-
// ------------------------------------------------------------------
|
|
605
|
-
// Uppercase
|
|
606
|
-
// ------------------------------------------------------------------
|
|
607
|
-
// prettier-ignore
|
|
608
|
-
const Uppercase = Runtime.Tuple([
|
|
609
|
-
Runtime.Const('Uppercase'),
|
|
610
|
-
Runtime.Const(LAngle),
|
|
611
|
-
Runtime.Ref('Type'),
|
|
612
|
-
Runtime.Const(RAngle),
|
|
613
|
-
], results => t.Uppercase(results[2]));
|
|
614
|
-
// ------------------------------------------------------------------
|
|
615
|
-
// Lowercase
|
|
616
|
-
// ------------------------------------------------------------------
|
|
617
|
-
// prettier-ignore
|
|
618
|
-
const Lowercase = Runtime.Tuple([
|
|
619
|
-
Runtime.Const('Lowercase'),
|
|
620
|
-
Runtime.Const(LAngle),
|
|
621
|
-
Runtime.Ref('Type'),
|
|
622
|
-
Runtime.Const(RAngle),
|
|
623
|
-
], results => t.Lowercase(results[2]));
|
|
624
|
-
// ------------------------------------------------------------------
|
|
625
|
-
// Capitalize
|
|
626
|
-
// ------------------------------------------------------------------
|
|
627
|
-
// prettier-ignore
|
|
628
|
-
const Capitalize = Runtime.Tuple([
|
|
629
|
-
Runtime.Const('Capitalize'),
|
|
630
|
-
Runtime.Const(LAngle),
|
|
631
|
-
Runtime.Ref('Type'),
|
|
632
|
-
Runtime.Const(RAngle),
|
|
633
|
-
], results => t.Capitalize(results[2]));
|
|
634
|
-
// ------------------------------------------------------------------
|
|
635
|
-
// Uncapitalize
|
|
636
|
-
// ------------------------------------------------------------------
|
|
637
|
-
// prettier-ignore
|
|
638
|
-
const Uncapitalize = Runtime.Tuple([
|
|
639
|
-
Runtime.Const('Uncapitalize'),
|
|
640
|
-
Runtime.Const(LAngle),
|
|
641
|
-
Runtime.Ref('Type'),
|
|
642
|
-
Runtime.Const(RAngle),
|
|
643
|
-
], results => t.Uncapitalize(results[2]));
|
|
644
|
-
// ------------------------------------------------------------------
|
|
645
|
-
// Date
|
|
646
|
-
// ------------------------------------------------------------------
|
|
647
|
-
const Date = Runtime.Const('Date', Runtime.As(t.Date()));
|
|
648
|
-
// ------------------------------------------------------------------
|
|
649
|
-
// Uint8Array
|
|
650
|
-
// ------------------------------------------------------------------
|
|
651
|
-
const Uint8Array = Runtime.Const('Uint8Array', Runtime.As(t.Uint8Array()));
|
|
652
|
-
// ------------------------------------------------------------------
|
|
653
|
-
// Module
|
|
654
|
-
// ------------------------------------------------------------------
|
|
655
|
-
// prettier-ignore
|
|
656
|
-
export const Module = new Runtime.Module({
|
|
657
|
-
GenericArgumentsList,
|
|
658
|
-
GenericArguments,
|
|
659
|
-
Literal,
|
|
660
|
-
Keyword,
|
|
661
|
-
KeyOf,
|
|
662
|
-
IndexArray,
|
|
663
|
-
Extends,
|
|
664
|
-
Base,
|
|
665
|
-
Factor,
|
|
666
|
-
ExprTermTail,
|
|
667
|
-
ExprTerm,
|
|
668
|
-
ExprTail,
|
|
669
|
-
Expr,
|
|
670
|
-
Type,
|
|
671
|
-
PropertyKey,
|
|
672
|
-
Readonly,
|
|
673
|
-
Optional,
|
|
674
|
-
Property,
|
|
675
|
-
PropertyDelimiter,
|
|
676
|
-
PropertyList,
|
|
677
|
-
Object: _Object,
|
|
678
|
-
ElementList,
|
|
679
|
-
Tuple,
|
|
680
|
-
Parameter,
|
|
681
|
-
ParameterList,
|
|
682
|
-
Function,
|
|
683
|
-
Constructor,
|
|
684
|
-
Mapped,
|
|
685
|
-
AsyncIterator,
|
|
686
|
-
Iterator,
|
|
687
|
-
Argument,
|
|
688
|
-
Awaited,
|
|
689
|
-
Array,
|
|
690
|
-
Record,
|
|
691
|
-
Promise,
|
|
692
|
-
ConstructorParameters,
|
|
693
|
-
FunctionParameters,
|
|
694
|
-
InstanceType,
|
|
695
|
-
ReturnType,
|
|
696
|
-
Partial,
|
|
697
|
-
Required,
|
|
698
|
-
Pick,
|
|
699
|
-
Omit,
|
|
700
|
-
Exclude,
|
|
701
|
-
Extract,
|
|
702
|
-
Uppercase,
|
|
703
|
-
Lowercase,
|
|
704
|
-
Capitalize,
|
|
705
|
-
Uncapitalize,
|
|
706
|
-
Date,
|
|
707
|
-
Uint8Array,
|
|
708
|
-
GenericReferenceParameters,
|
|
709
|
-
GenericReference,
|
|
710
|
-
Reference,
|
|
711
|
-
});
|