typebox 1.3.8 → 1.3.10
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/system/settings/settings.d.mts +9 -0
- package/build/system/settings/settings.mjs +2 -0
- package/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/build/type/engine/call/instantiate.mjs +34 -4
- package/build/type/script/mapping.d.mts +32 -29
- package/build/type/script/mapping.mjs +18 -25
- package/build/type/script/parser.d.mts +19 -25
- package/build/type/script/parser.mjs +19 -22
- package/package.json +28 -28
- package/readme.md +56 -54
|
@@ -16,6 +16,15 @@ export interface TSettings {
|
|
|
16
16
|
* @default 8
|
|
17
17
|
*/
|
|
18
18
|
maxErrors: number;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the maximum number of instantiations allowed within a top-level generic instantiation
|
|
21
|
+
* context. This setting can be used to bound generic calls to a fixed count, which can be useful if
|
|
22
|
+
* evaluating string-encoded types originating from untrusted sources. Setting this value to 0 will
|
|
23
|
+
* disallow generics entirely, ensuring type instantiation runs linear.
|
|
24
|
+
*
|
|
25
|
+
* @default 128
|
|
26
|
+
*/
|
|
27
|
+
maxInstantiationCount: number;
|
|
19
28
|
/**
|
|
20
29
|
* Enables or disables the use of runtime code evaluation to accelerate validation. By default,
|
|
21
30
|
* TypeBox checks for `unsafe-eval` support in the environment before attempting to evaluate
|
|
@@ -3,6 +3,7 @@ import { Guard } from '../../guard/index.mjs';
|
|
|
3
3
|
const settings = {
|
|
4
4
|
immutableTypes: false,
|
|
5
5
|
maxErrors: 8,
|
|
6
|
+
maxInstantiationCount: 128,
|
|
6
7
|
useAcceleration: true,
|
|
7
8
|
exactOptionalPropertyTypes: false,
|
|
8
9
|
enumerableKind: false,
|
|
@@ -13,6 +14,7 @@ const settings = {
|
|
|
13
14
|
export function Reset() {
|
|
14
15
|
settings.immutableTypes = false;
|
|
15
16
|
settings.maxErrors = 8;
|
|
17
|
+
settings.maxInstantiationCount = 128;
|
|
16
18
|
settings.useAcceleration = true;
|
|
17
19
|
settings.exactOptionalPropertyTypes = false;
|
|
18
20
|
settings.enumerableKind = false;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TUnion } from '../../types/union.mjs';
|
|
3
3
|
import { type TDeferred } from '../../types/deferred.mjs';
|
|
4
|
+
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
5
|
+
import { type TTemplateLiteral } from '../../types/template_literal.mjs';
|
|
4
6
|
import { type TRef } from '../../types/ref.mjs';
|
|
5
7
|
import { type TParameter } from '../../types/parameter.mjs';
|
|
8
|
+
import { type TEvaluateTemplateLiteral } from '../evaluate/evaluate.mjs';
|
|
9
|
+
import { type TEvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
6
10
|
type TCollectDistributionNames<Expression extends TSchema, Result extends string[] = []> = (Expression extends TDeferred<'Conditional', [infer Left extends TSchema, infer _Right extends TSchema, infer True extends TSchema, infer False extends TSchema]> ? Left extends TRef ? TCollectDistributionNames<True, TCollectDistributionNames<False, [...Result, Left['$ref']]>> : TCollectDistributionNames<True, TCollectDistributionNames<False, Result>> : Expression extends TDeferred<'Mapped', [infer _Identifier extends TSchema, infer Type extends TSchema, infer _As extends TSchema, infer _Property extends TSchema]> ? (Type extends TDeferred<'KeyOf', [infer Ref extends TRef]> ? [...Result, Ref['$ref']] : Result) : Result);
|
|
7
11
|
type TBuildDistributionArray<Parameters extends TParameter[], Names extends string[], Result extends boolean[] = []> = (Parameters extends [infer Left extends TParameter, ...infer Right extends TParameter[]] ? Left['name'] extends Names[number] ? TBuildDistributionArray<Right, Names, [...Result, true]> : TBuildDistributionArray<Right, Names, [...Result, false]> : Result);
|
|
8
12
|
type TZipDistributionArray<Arguments extends TSchema[], DistributionArray extends boolean[], Result extends [boolean, TSchema][] = []> = (Arguments extends [infer ArgumentLeft extends TSchema, ...infer ArgumentRight extends TSchema[]] ? DistributionArray extends [infer BooleanLeft extends boolean, ...infer BooleanRight extends boolean[]] ? TZipDistributionArray<ArgumentRight, BooleanRight, [...Result, [BooleanLeft, ArgumentLeft]]> : Result : Result);
|
|
9
|
-
type
|
|
13
|
+
type TCanonicalArgument<Type extends TSchema> = (Type extends TTemplateLiteral<infer Pattern extends string> ? TEvaluateTemplateLiteral<Pattern> : Type extends TEnum<infer Values extends TEnumValue[]> ? TEvaluateEnum<Values> : Type);
|
|
14
|
+
type TExpand<Argument extends TSchema, CanonicalArgument extends TSchema = TCanonicalArgument<Argument>> = (CanonicalArgument extends TUnion<infer Types extends TSchema[]> ? [...Types] : [CanonicalArgument]);
|
|
10
15
|
type TAppend<Current extends TSchema[][], Type extends TSchema, Result extends TSchema[][] = []> = (Current extends [infer Left extends TSchema[], ...infer Right extends TSchema[][]] ? TAppend<Right, Type, [...Result, [...Left, Type]]> : Result);
|
|
11
16
|
type TCross<Current extends TSchema[][], Variants extends TSchema[], Result extends TSchema[][] = []> = (Variants extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TCross<Current, Right, [...Result, ...TAppend<Current, Left>]> : Result);
|
|
12
17
|
type TDistribute<ZippedArguments extends [boolean, TSchema][], Result extends TSchema[][] = [[]]> = (ZippedArguments extends [infer Left extends [boolean, TSchema], ...infer Right extends [boolean, TSchema][]] ? Left[0] extends true ? TDistribute<Right, TCross<Result, TExpand<Left[1]>>> : TDistribute<Right, TCross<Result, [Left[1]]>> : Result);
|
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
3
|
import { IsUnion } from '../../types/union.mjs';
|
|
4
4
|
import { IsDeferred } from '../../types/deferred.mjs';
|
|
5
|
+
import { IsEnum } from '../../types/enum.mjs';
|
|
6
|
+
import { IsTemplateLiteral } from '../../types/template_literal.mjs';
|
|
5
7
|
import { IsRef } from '../../types/ref.mjs';
|
|
8
|
+
// ------------------------------------------------------------------
|
|
9
|
+
// Infrastructure
|
|
10
|
+
// ------------------------------------------------------------------
|
|
11
|
+
import { EvaluateTemplateLiteral } from '../evaluate/evaluate.mjs';
|
|
12
|
+
import { EvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
6
13
|
function CollectDistributionNames(expression, result = []) {
|
|
7
14
|
return (
|
|
8
15
|
// Conditional
|
|
@@ -21,10 +28,16 @@ function BuildDistributionArray(parameters, names) {
|
|
|
21
28
|
function ZipDistributionArray(arguments_, distributionArray, result = []) {
|
|
22
29
|
return Guard.ShiftLeft(arguments_, (argumentLeft, argumentRight) => Guard.ShiftLeft(distributionArray, (booleanLeft, booleanRight) => ZipDistributionArray(argumentRight, booleanRight, [...result, [booleanLeft, argumentLeft]]), () => result), () => result);
|
|
23
30
|
}
|
|
31
|
+
function CanonicalArgument(type) {
|
|
32
|
+
return (IsTemplateLiteral(type) ? EvaluateTemplateLiteral(type.pattern) :
|
|
33
|
+
IsEnum(type) ? EvaluateEnum(type.enum) :
|
|
34
|
+
type);
|
|
35
|
+
}
|
|
24
36
|
function Expand(type) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
const canonicalArgument = CanonicalArgument(type);
|
|
38
|
+
return (IsUnion(canonicalArgument)
|
|
39
|
+
? [...canonicalArgument.anyOf]
|
|
40
|
+
: [canonicalArgument]);
|
|
28
41
|
}
|
|
29
42
|
function Append(current, type) {
|
|
30
43
|
return current.reduce((result, left) => [...result, [...left, type]], []);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { Settings } from '../../../system/settings/index.mjs';
|
|
2
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
4
|
import { CallConstruct } from '../../types/call.mjs';
|
|
4
5
|
import { Ref } from '../../types/ref.mjs';
|
|
@@ -13,6 +14,26 @@ import { State } from '../instantiate.mjs';
|
|
|
13
14
|
import { DistributeArguments } from './distribute_arguments.mjs';
|
|
14
15
|
import { ResolveTarget } from './resolve_target.mjs';
|
|
15
16
|
import { ResolveArgumentsContext } from './resolve_arguments.mjs';
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
// InstantiationGuard
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
let instantiationDepth = 0;
|
|
21
|
+
let instantiationCount = 0;
|
|
22
|
+
function InstantiationAssert() {
|
|
23
|
+
if (Guard.IsLessThan(instantiationCount, Settings.Get().maxInstantiationCount))
|
|
24
|
+
return;
|
|
25
|
+
throw Error('Type instantiation is excessively deep and possibly infinite');
|
|
26
|
+
}
|
|
27
|
+
function InstantiationIncrement() {
|
|
28
|
+
InstantiationAssert();
|
|
29
|
+
instantiationCount++;
|
|
30
|
+
instantiationDepth++;
|
|
31
|
+
}
|
|
32
|
+
function InstantiationDecrement() {
|
|
33
|
+
instantiationDepth--;
|
|
34
|
+
if (Guard.IsEqual(instantiationDepth, 0))
|
|
35
|
+
instantiationCount = 0;
|
|
36
|
+
}
|
|
16
37
|
function Peek(state) {
|
|
17
38
|
const result = Guard.IsGreaterThan(state.callstack.length, 0) ? state.callstack[state.callstack.length - 1] : '';
|
|
18
39
|
return result;
|
|
@@ -22,12 +43,21 @@ function IsTailCall(state, name) {
|
|
|
22
43
|
return result;
|
|
23
44
|
}
|
|
24
45
|
function CallDispatch(context, state, target, parameters, expression, arguments_) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
InstantiationIncrement();
|
|
47
|
+
try {
|
|
48
|
+
const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
|
|
49
|
+
const returnType = InstantiateType(argumentsContext, State([...state['callstack'], target['$ref']], state['visited']), expression);
|
|
50
|
+
return InstantiateType(argumentsContext, State([], []), returnType);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
InstantiationDecrement();
|
|
54
|
+
}
|
|
28
55
|
}
|
|
29
56
|
function CallDistributed(context, state, target, parameters, expression, distributedArguments) {
|
|
30
|
-
return distributedArguments.reduce((result, arguments_) =>
|
|
57
|
+
return distributedArguments.reduce((result, arguments_) => {
|
|
58
|
+
const returnType = CallDispatch(context, state, target, parameters, expression, arguments_);
|
|
59
|
+
return [...result, returnType];
|
|
60
|
+
}, []);
|
|
31
61
|
}
|
|
32
62
|
function CallImmediate(context, state, target, parameters, expression, arguments_) {
|
|
33
63
|
const distributedArguments = DistributeArguments(parameters, arguments_, expression);
|
|
@@ -65,8 +65,8 @@ type TIntrinsicOrCall<Target extends string, Parameters extends T.TSchema[]> = (
|
|
|
65
65
|
Target,
|
|
66
66
|
Parameters
|
|
67
67
|
] extends ['Uppercase', [infer Type extends T.TSchema]] ? S.TUppercaseDeferred<Type> : T.TCallConstruct<T.TRef<Target>, Parameters>);
|
|
68
|
-
type TDelimitedDecode<Input extends
|
|
69
|
-
type TDelimited<Input extends [unknown, unknown]> = Input extends [infer Left extends unknown[], infer
|
|
68
|
+
type TDelimitedDecode<Input extends [unknown, unknown][], Result extends unknown[] = []> = (Input extends [infer Left extends [unknown, unknown], ...infer Right extends [unknown, unknown][]] ? TDelimitedDecode<Right, [...Result, Left[1]]> : Result);
|
|
69
|
+
type TDelimited<Input extends [unknown, unknown, unknown] | []> = (Input extends [infer Left extends unknown, infer Right extends [unknown, unknown][], infer _ extends unknown[]] ? [Left, ...TDelimitedDecode<Right>] : []);
|
|
70
70
|
export type TGenericParameterExtendsEqualsMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends [infer Name extends string, 'extends', infer Extends extends T.TSchema, '=', infer Equals extends T.TSchema] ? T.TParameter<Name, Extends, Equals> : never);
|
|
71
71
|
export declare function GenericParameterExtendsEqualsMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
72
72
|
export type TGenericParameterExtendsMapping<Input extends [unknown, unknown, unknown]> = (Input extends [infer Name extends string, 'extends', infer Extends extends T.TSchema] ? T.TParameter<Name, Extends, Extends> : never);
|
|
@@ -77,12 +77,12 @@ export type TGenericParameterIdentifierMapping<Input extends string, Result exte
|
|
|
77
77
|
export declare function GenericParameterIdentifierMapping(input: string): unknown;
|
|
78
78
|
export type TGenericParameterMapping<Input extends unknown> = (Input);
|
|
79
79
|
export declare function GenericParameterMapping(input: unknown): unknown;
|
|
80
|
-
export type TGenericParameterListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
81
|
-
export declare function GenericParameterListMapping(input: [unknown, unknown]): unknown;
|
|
80
|
+
export type TGenericParameterListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
81
|
+
export declare function GenericParameterListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
82
82
|
export type TGenericParametersMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['<', infer Parameters extends T.TParameter[], '>'] ? Parameters : never);
|
|
83
83
|
export declare function GenericParametersMapping(input: [unknown, unknown, unknown]): unknown;
|
|
84
|
-
export type TGenericCallArgumentListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
85
|
-
export declare function GenericCallArgumentListMapping(input: [unknown, unknown]): unknown;
|
|
84
|
+
export type TGenericCallArgumentListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
85
|
+
export declare function GenericCallArgumentListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
86
86
|
export type TGenericCallArgumentsMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['<', infer Arguments extends T.TSchema[], '>'] ? Arguments : never);
|
|
87
87
|
export declare function GenericCallArgumentsMapping(input: [unknown, unknown, unknown]): unknown;
|
|
88
88
|
export type TGenericCallMapping<Input extends [unknown, unknown], Result = Input extends [infer Ref extends string, infer Arguments extends T.TSchema[]] ? TIntrinsicOrCall<Ref, Arguments> : never> = Result;
|
|
@@ -202,8 +202,8 @@ export type TPropertyMapping<Input extends [unknown, unknown, unknown, unknown,
|
|
|
202
202
|
export declare function PropertyMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
203
203
|
export type TPropertyDelimiterMapping<Input extends [unknown, unknown] | [unknown]> = (Input);
|
|
204
204
|
export declare function PropertyDelimiterMapping(input: [unknown, unknown] | [unknown]): unknown;
|
|
205
|
-
export type TPropertyListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
206
|
-
export declare function PropertyListMapping(input: [unknown, unknown]): unknown;
|
|
205
|
+
export type TPropertyListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
206
|
+
export declare function PropertyListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
207
207
|
type TPropertiesReduce<PropertiesList extends T.TProperties[], Result extends [properties: T.TProperties, patternProperties: T.TProperties] = [{}, {}]> = (PropertiesList extends [infer Left extends T.TProperties, ...infer Right extends T.TProperties[]] ? (Left extends {
|
|
208
208
|
[_ in T.TIntegerKey]: T.TSchema;
|
|
209
209
|
} ? TPropertiesReduce<Right, [Result[0], Memory.TAssign<Result[1], Left>]> : Left extends {
|
|
@@ -219,18 +219,21 @@ export type T_Object_Mapping<Input extends unknown> = (Input extends [infer Prop
|
|
|
219
219
|
export declare function _Object_Mapping(input: unknown): unknown;
|
|
220
220
|
export type TElementNamedMapping<Input extends [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown]> = (Input extends [string, '?', ':', 'readonly', infer Type extends T.TSchema] ? S.TAddReadonlyDeferred<S.TAddOptionalDeferred<Type>> : Input extends [string, /**/ ':', 'readonly', infer Type extends T.TSchema] ? S.TAddReadonlyDeferred<Type> : Input extends [string, '?', ':', /* */ infer Type extends T.TSchema] ? S.TAddOptionalDeferred<Type> : Input extends [string, /**/ ':', /* */ infer Type extends T.TSchema] ? Type : never);
|
|
221
221
|
export declare function ElementNamedMapping(input: [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown]): unknown;
|
|
222
|
-
export type
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
222
|
+
export type TElementBaseMapping<Input extends unknown | [unknown, unknown, unknown]> = (Input extends [infer IsReadonly extends boolean, infer Type extends T.TSchema, infer IsOptional extends boolean] ? ([
|
|
223
|
+
IsReadonly,
|
|
224
|
+
IsOptional
|
|
225
|
+
] extends [true, true] ? S.TAddReadonlyDeferred<S.TAddOptionalDeferred<Type>> : [
|
|
226
|
+
IsReadonly,
|
|
227
|
+
IsOptional
|
|
228
|
+
] extends [true, false] ? S.TAddReadonlyDeferred<Type> : [
|
|
229
|
+
IsReadonly,
|
|
230
|
+
IsOptional
|
|
231
|
+
] extends [false, true] ? S.TAddOptionalDeferred<Type> : Type) : Input);
|
|
232
|
+
export declare function ElementBaseMapping(input: unknown | [unknown, unknown, unknown]): unknown;
|
|
230
233
|
export type TElementMapping<Input extends [unknown, unknown] | [unknown]> = (Input extends ['...', infer Type extends T.TSchema] ? T.TRest<Type> : Input extends [infer Type extends T.TSchema] ? Type : never);
|
|
231
234
|
export declare function ElementMapping(input: [unknown, unknown] | [unknown]): unknown;
|
|
232
|
-
export type TElementListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
233
|
-
export declare function ElementListMapping(input: [unknown, unknown]): unknown;
|
|
235
|
+
export type TElementListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
236
|
+
export declare function ElementListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
234
237
|
export type T_Tuple_Mapping<Input extends [unknown, unknown, unknown]> = (Input extends ['[', infer Types extends T.TSchema[], ']'] ? T.TTuple<Types> : never);
|
|
235
238
|
export declare function _Tuple_Mapping(input: [unknown, unknown, unknown]): unknown;
|
|
236
239
|
export type TParameterReadonlyOptionalMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends [string, '?', ':', 'readonly', infer Type extends T.TSchema] ? S.TAddReadonlyDeferred<S.TAddOptionalDeferred<Type>> : never);
|
|
@@ -245,8 +248,8 @@ export type TParameterBaseMapping<Input extends unknown> = (Input);
|
|
|
245
248
|
export declare function ParameterBaseMapping(input: unknown): unknown;
|
|
246
249
|
export type TParameterMapping<Input extends [unknown, unknown] | [unknown]> = (Input extends ['...', infer Type extends T.TSchema] ? T.TRest<Type> : Input extends [infer Type extends T.TSchema] ? Type : never);
|
|
247
250
|
export declare function ParameterMapping(input: [unknown, unknown] | [unknown]): unknown;
|
|
248
|
-
export type TParameterListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
249
|
-
export declare function ParameterListMapping(input: [unknown, unknown]): unknown;
|
|
251
|
+
export type TParameterListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
252
|
+
export declare function ParameterListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
250
253
|
export type T_Function_Mapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends ['(', infer ParameterList extends T.TSchema[], ')', '=>', infer ReturnType extends T.TSchema] ? T.TFunction<ParameterList, ReturnType> : never);
|
|
251
254
|
export declare function _Function_Mapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
252
255
|
export type T_Constructor_Mapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown]> = (Input extends ['new', '(', infer ParameterList extends T.TSchema[], ')', '=>', infer InstanceType extends T.TSchema] ? T.TConstructor<ParameterList, InstanceType> : never);
|
|
@@ -280,15 +283,15 @@ export type TWithPropertyMapping<Input extends [unknown, unknown, unknown]> = (I
|
|
|
280
283
|
[_ in Key]: Value;
|
|
281
284
|
} : never);
|
|
282
285
|
export declare function WithPropertyMapping(input: [unknown, unknown, unknown]): unknown;
|
|
283
|
-
export type TWithPropertyListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
284
|
-
export declare function WithPropertyListMapping(input: [unknown, unknown]): unknown;
|
|
286
|
+
export type TWithPropertyListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
287
|
+
export declare function WithPropertyListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
285
288
|
type TWithObjectMappingReduce<PropertyList extends Record<PropertyKey, unknown>[], Result extends Record<PropertyKey, unknown> = {}> = (PropertyList extends [infer Left extends Record<PropertyKey, unknown>, ...infer Right extends Record<PropertyKey, unknown>[]] ? TWithObjectMappingReduce<Right, Memory.TAssign<Result, Left>> : {
|
|
286
289
|
[Key in keyof Result]: Result[Key];
|
|
287
290
|
});
|
|
288
291
|
export type TWithObjectMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['{', infer PropertyList extends Record<PropertyKey, unknown>[], '}'] ? TWithObjectMappingReduce<PropertyList> : {});
|
|
289
292
|
export declare function WithObjectMapping(input: [unknown, unknown, unknown]): unknown;
|
|
290
|
-
export type TWithElementListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
291
|
-
export declare function WithElementListMapping(input: [unknown, unknown]): unknown;
|
|
293
|
+
export type TWithElementListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
294
|
+
export declare function WithElementListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
292
295
|
export type TWithArrayMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['[', infer Elements extends unknown[], ']'] ? Elements : never);
|
|
293
296
|
export declare function WithArrayMapping(input: [unknown, unknown, unknown]): unknown;
|
|
294
297
|
export type TWithValueMapping<Input extends unknown> = (Input);
|
|
@@ -318,8 +321,8 @@ export type TPatternBodyMapping<Input extends unknown> = (Input);
|
|
|
318
321
|
export declare function PatternBodyMapping(input: unknown): unknown;
|
|
319
322
|
export type TPatternMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['^', infer Body extends T.TSchema[], '$'] ? Body : never);
|
|
320
323
|
export declare function PatternMapping(input: [unknown, unknown, unknown]): unknown;
|
|
321
|
-
export type TInterfaceDeclarationHeritageListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
322
|
-
export declare function InterfaceDeclarationHeritageListMapping(input: [unknown, unknown]): unknown;
|
|
324
|
+
export type TInterfaceDeclarationHeritageListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
325
|
+
export declare function InterfaceDeclarationHeritageListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
323
326
|
export type TInterfaceDeclarationHeritageMapping<Input extends [unknown, unknown] | []> = (Input extends ['extends', infer Heritage extends T.TSchema[]] ? Heritage : []);
|
|
324
327
|
export declare function InterfaceDeclarationHeritageMapping(input: [unknown, unknown] | []): unknown;
|
|
325
328
|
export type TInterfaceDeclarationGenericMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends ['interface', infer Name extends string, infer Parameters extends T.TParameter[], infer Heritage extends T.TSchema[], infer Properties extends [T.TProperties, T.TProperties]] ? {
|
|
@@ -342,11 +345,11 @@ export type TExportKeywordMapping<Input extends [unknown] | []> = (null);
|
|
|
342
345
|
export declare function ExportKeywordMapping(input: [unknown] | []): unknown;
|
|
343
346
|
export type TModuleDeclarationDelimiterMapping<Input extends [unknown, unknown] | [unknown]> = (Input);
|
|
344
347
|
export declare function ModuleDeclarationDelimiterMapping(input: [unknown, unknown] | [unknown]): unknown;
|
|
345
|
-
export type TModuleDeclarationListMapping<Input extends [unknown, unknown]> = (
|
|
346
|
-
export declare function ModuleDeclarationListMapping(input: [unknown, unknown]): unknown;
|
|
348
|
+
export type TModuleDeclarationListMapping<Input extends [unknown, unknown, unknown] | []> = (TDelimited<Input>);
|
|
349
|
+
export declare function ModuleDeclarationListMapping(input: [unknown, unknown, unknown] | []): unknown;
|
|
347
350
|
export type TModuleDeclarationMapping<Input extends [unknown, unknown, unknown]> = (Input extends [null, infer ModuleDeclaration extends T.TProperties, null] ? ModuleDeclaration : never);
|
|
348
351
|
export declare function ModuleDeclarationMapping(input: [unknown, unknown, unknown]): unknown;
|
|
349
|
-
export type TModuleMapping<Input extends [unknown, unknown]> = (Input extends [infer ModuleDeclaration extends T.TProperties, infer ModuleDeclarationList extends
|
|
352
|
+
export type TModuleMapping<Input extends [unknown, unknown]> = (Input extends [infer ModuleDeclaration extends T.TProperties, infer ModuleDeclarationList extends T.TProperties[]] ? S.TModuleDeferred<Memory.TAssign<ModuleDeclaration, TPropertiesReduce<ModuleDeclarationList>[0]>> : never);
|
|
350
353
|
export declare function ModuleMapping(input: [unknown, unknown]): unknown;
|
|
351
354
|
export type TScriptMapping<Input extends unknown> = (Input);
|
|
352
355
|
export declare function ScriptMapping(input: unknown): unknown;
|
|
@@ -39,17 +39,14 @@ function IntrinsicOrCall(ref, parameters) {
|
|
|
39
39
|
function Unreachable() {
|
|
40
40
|
throw Error('Unreachable');
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const [left, right] = input;
|
|
51
|
-
return DelimitedDecode([...left, ...right]);
|
|
52
|
-
};
|
|
42
|
+
function DelimitedDecode(input, result = []) {
|
|
43
|
+
return Guard.ShiftLeft(input, (left, right) => DelimitedDecode(right, [...result, left[1]]), () => result);
|
|
44
|
+
}
|
|
45
|
+
function Delimited(input) {
|
|
46
|
+
return Guard.IsEqual(input.length, 3)
|
|
47
|
+
? [input[0], ...DelimitedDecode(input[1])]
|
|
48
|
+
: [];
|
|
49
|
+
}
|
|
53
50
|
export function GenericParameterExtendsEqualsMapping(input) {
|
|
54
51
|
return T.Parameter(input[0], input[2], input[4]);
|
|
55
52
|
}
|
|
@@ -322,17 +319,14 @@ export function ElementNamedMapping(input) {
|
|
|
322
319
|
Guard.IsEqual(input.length, 4) ? (Guard.IsEqual(input[2], 'readonly') ? S.AddReadonlyDeferred(input[3]) : S.AddOptionalDeferred(input[3])) :
|
|
323
320
|
Unreachable());
|
|
324
321
|
}
|
|
325
|
-
export function ElementReadonlyOptionalMapping(input) {
|
|
326
|
-
return S.AddReadonlyDeferred(S.AddOptionalDeferred(input[1]));
|
|
327
|
-
}
|
|
328
|
-
export function ElementReadonlyMapping(input) {
|
|
329
|
-
return S.AddReadonlyDeferred(input[1]);
|
|
330
|
-
}
|
|
331
|
-
export function ElementOptionalMapping(input) {
|
|
332
|
-
return S.AddOptionalDeferred(input[0]);
|
|
333
|
-
}
|
|
334
322
|
export function ElementBaseMapping(input) {
|
|
335
|
-
|
|
323
|
+
if (!Guard.IsArray(input) || !Guard.IsEqual(input.length, 3))
|
|
324
|
+
return input;
|
|
325
|
+
const [isReadonly, type, isOptional] = input;
|
|
326
|
+
return (isReadonly && isOptional ? S.AddReadonlyDeferred(S.AddOptionalDeferred(type)) :
|
|
327
|
+
isReadonly && !isOptional ? S.AddReadonlyDeferred(type) :
|
|
328
|
+
!isReadonly && isOptional ? S.AddOptionalDeferred(type) :
|
|
329
|
+
type);
|
|
336
330
|
}
|
|
337
331
|
// deno-coverage-ignore-start
|
|
338
332
|
export function ElementMapping(input) {
|
|
@@ -520,15 +514,14 @@ export function ModuleDeclarationDelimiterMapping(input) {
|
|
|
520
514
|
return input;
|
|
521
515
|
}
|
|
522
516
|
export function ModuleDeclarationListMapping(input) {
|
|
523
|
-
return
|
|
517
|
+
return Delimited(input);
|
|
524
518
|
}
|
|
525
519
|
export function ModuleDeclarationMapping(input) {
|
|
526
520
|
return input[1];
|
|
527
521
|
}
|
|
528
522
|
export function ModuleMapping(input) {
|
|
529
|
-
const moduleDeclaration = input[0];
|
|
530
|
-
|
|
531
|
-
return S.ModuleDeferred(Memory.Assign(moduleDeclaration, moduleDeclarationList[0]));
|
|
523
|
+
const [moduleDeclaration, moduleDeclarationList] = [input[0], input[1]];
|
|
524
|
+
return S.ModuleDeferred(Memory.Assign(moduleDeclaration, PropertiesReduce(moduleDeclarationList)[0]));
|
|
532
525
|
}
|
|
533
526
|
export function ScriptMapping(input) {
|
|
534
527
|
return input;
|
|
@@ -5,11 +5,11 @@ export type TGenericParameterExtends<Input extends string> = (Token.TIdent<Input
|
|
|
5
5
|
export type TGenericParameterEquals<Input extends string> = (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'=', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TGenericParameterEqualsMapping<_0>, Input] : [];
|
|
6
6
|
export type TGenericParameterIdentifier<Input extends string> = Token.TIdent<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TGenericParameterIdentifierMapping<_0>, Input] : [];
|
|
7
7
|
export type TGenericParameter<Input extends string> = (TGenericParameterExtendsEquals<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericParameterExtends<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericParameterEquals<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericParameterIdentifier<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TGenericParameterMapping<_0>, Input] : [];
|
|
8
|
-
export type TGenericParameterList_0<Input extends string, Result extends unknown[] = []> = (
|
|
9
|
-
export type TGenericParameterList<Input extends string> = (
|
|
8
|
+
export type TGenericParameterList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TGenericParameter<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TGenericParameterList_0<Input, [...Result, _0]> : [Result, Input];
|
|
9
|
+
export type TGenericParameterList<Input extends string> = ((TGenericParameter<Input> extends [infer _0, infer Input extends string] ? (TGenericParameterList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TGenericParameterListMapping<_0>, Input] : [];
|
|
10
10
|
export type TGenericParameters<Input extends string> = (Token.TConst<'<', Input> extends [infer _0, infer Input extends string] ? (TGenericParameterList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'>', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TGenericParametersMapping<_0>, Input] : [];
|
|
11
|
-
export type TGenericCallArgumentList_0<Input extends string, Result extends unknown[] = []> = (
|
|
12
|
-
export type TGenericCallArgumentList<Input extends string> = (
|
|
11
|
+
export type TGenericCallArgumentList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TGenericCallArgumentList_0<Input, [...Result, _0]> : [Result, Input];
|
|
12
|
+
export type TGenericCallArgumentList<Input extends string> = ((TType<Input> extends [infer _0, infer Input extends string] ? (TGenericCallArgumentList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TGenericCallArgumentListMapping<_0>, Input] : [];
|
|
13
13
|
export type TGenericCallArguments<Input extends string> = (Token.TConst<'<', Input> extends [infer _0, infer Input extends string] ? (TGenericCallArgumentList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'>', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TGenericCallArgumentsMapping<_0>, Input] : [];
|
|
14
14
|
export type TGenericCall<Input extends string> = (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (TGenericCallArguments<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TGenericCallMapping<_0>, Input] : [];
|
|
15
15
|
export type TOptionalSemiColon<Input extends string> = ((Token.TConst<';', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown] | [], infer Input extends string] ? [S.TOptionalSemiColonMapping<_0>, Input] : [];
|
|
@@ -62,18 +62,15 @@ export type TReadonly<Input extends string> = ((Token.TConst<'readonly', Input>
|
|
|
62
62
|
export type TOptional<Input extends string> = ((Token.TConst<'?', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown] | [], infer Input extends string] ? [S.TOptionalMapping<_0>, Input] : [];
|
|
63
63
|
export type TProperty<Input extends string> = (TReadonly<Input> extends [infer _0, infer Input extends string] ? (TPropertyKey<Input> extends [infer _1, infer Input extends string] ? (TOptional<Input> extends [infer _2, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _3, infer Input extends string] ? (TType<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TPropertyMapping<_0>, Input] : [];
|
|
64
64
|
export type TPropertyDelimiter<Input extends string> = ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'\n', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<';', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'\n', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<';', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'\n', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown], infer Input extends string] ? [S.TPropertyDelimiterMapping<_0>, Input] : [];
|
|
65
|
-
export type TPropertyList_0<Input extends string, Result extends unknown[] = []> = (
|
|
66
|
-
export type TPropertyList<Input extends string> = (
|
|
65
|
+
export type TPropertyList_0<Input extends string, Result extends unknown[] = []> = (TPropertyDelimiter<Input> extends [infer _0, infer Input extends string] ? (TProperty<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TPropertyList_0<Input, [...Result, _0]> : [Result, Input];
|
|
66
|
+
export type TPropertyList<Input extends string> = ((TProperty<Input> extends [infer _0, infer Input extends string] ? (TPropertyList_0<Input> extends [infer _1, infer Input extends string] ? ((TPropertyDelimiter<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TPropertyListMapping<_0>, Input] : [];
|
|
67
67
|
export type TProperties<Input extends string> = (Token.TConst<'{', Input> extends [infer _0, infer Input extends string] ? (TPropertyList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'}', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TPropertiesMapping<_0>, Input] : [];
|
|
68
68
|
export type T_Object_<Input extends string> = TProperties<Input> extends [infer _0 extends unknown, infer Input extends string] ? [S.T_Object_Mapping<_0>, Input] : [];
|
|
69
69
|
export type TElementNamed<Input extends string> = ((Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _2, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _3, infer Input extends string] ? (TType<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown] | [unknown, unknown, unknown], infer Input extends string] ? [S.TElementNamedMapping<_0>, Input] : [];
|
|
70
|
-
export type
|
|
71
|
-
export type TElementReadonly<Input extends string> = (Token.TConst<'readonly', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TElementReadonlyMapping<_0>, Input] : [];
|
|
72
|
-
export type TElementOptional<Input extends string> = (TType<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TElementOptionalMapping<_0>, Input] : [];
|
|
73
|
-
export type TElementBase<Input extends string> = (TElementNamed<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TElementReadonlyOptional<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TElementReadonly<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TElementOptional<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TElementBaseMapping<_0>, Input] : [];
|
|
70
|
+
export type TElementBase<Input extends string> = (TElementNamed<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : (TReadonly<Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (TOptional<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown | [unknown, unknown, unknown], infer Input extends string] ? [S.TElementBaseMapping<_0>, Input] : [];
|
|
74
71
|
export type TElement<Input extends string> = ((Token.TConst<'...', Input> extends [infer _0, infer Input extends string] ? (TElementBase<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TElementBase<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown], infer Input extends string] ? [S.TElementMapping<_0>, Input] : [];
|
|
75
|
-
export type TElementList_0<Input extends string, Result extends unknown[] = []> = (
|
|
76
|
-
export type TElementList<Input extends string> = (
|
|
72
|
+
export type TElementList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TElement<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TElementList_0<Input, [...Result, _0]> : [Result, Input];
|
|
73
|
+
export type TElementList<Input extends string> = ((TElement<Input> extends [infer _0, infer Input extends string] ? (TElementList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TElementListMapping<_0>, Input] : [];
|
|
77
74
|
export type T_Tuple_<Input extends string> = (Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (TElementList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.T_Tuple_Mapping<_0>, Input] : [];
|
|
78
75
|
export type TParameterReadonlyOptional<Input extends string> = (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _2, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _3, infer Input extends string] ? (TType<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TParameterReadonlyOptionalMapping<_0>, Input] : [];
|
|
79
76
|
export type TParameterReadonly<Input extends string> = (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TParameterReadonlyMapping<_0>, Input] : [];
|
|
@@ -81,8 +78,8 @@ export type TParameterOptional<Input extends string> = (Token.TIdent<Input> exte
|
|
|
81
78
|
export type TParameterType<Input extends string> = (Token.TIdent<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TParameterTypeMapping<_0>, Input] : [];
|
|
82
79
|
export type TParameterBase<Input extends string> = (TParameterReadonlyOptional<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TParameterReadonly<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TParameterOptional<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TParameterType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TParameterBaseMapping<_0>, Input] : [];
|
|
83
80
|
export type TParameter<Input extends string> = ((Token.TConst<'...', Input> extends [infer _0, infer Input extends string] ? (TParameterBase<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TParameterBase<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown], infer Input extends string] ? [S.TParameterMapping<_0>, Input] : [];
|
|
84
|
-
export type TParameterList_0<Input extends string, Result extends unknown[] = []> = (
|
|
85
|
-
export type TParameterList<Input extends string> = (
|
|
81
|
+
export type TParameterList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TParameter<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TParameterList_0<Input, [...Result, _0]> : [Result, Input];
|
|
82
|
+
export type TParameterList<Input extends string> = ((TParameter<Input> extends [infer _0, infer Input extends string] ? (TParameterList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TParameterListMapping<_0>, Input] : [];
|
|
86
83
|
export type T_Function_<Input extends string> = (Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TParameterList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? (Token.TConst<'=>', Input> extends [infer _3, infer Input extends string] ? (TType<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.T_Function_Mapping<_0>, Input] : [];
|
|
87
84
|
export type T_Constructor_<Input extends string> = (Token.TConst<'new', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'(', Input> extends [infer _1, infer Input extends string] ? (TParameterList<Input> extends [infer _2, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'=>', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.T_Constructor_Mapping<_0>, Input] : [];
|
|
88
85
|
export type TMappedReadonly<Input extends string> = ((Token.TConst<'+', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'-', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'readonly', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'readonly', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown] | [], infer Input extends string] ? [S.TMappedReadonlyMapping<_0>, Input] : [];
|
|
@@ -97,11 +94,11 @@ export type TWithString<Input extends string> = Token.TString<['\"', '\''], Inpu
|
|
|
97
94
|
export type TWithNull<Input extends string> = Token.TConst<'null', Input> extends [infer _0 extends 'null', infer Input extends string] ? [S.TWithNullMapping<_0>, Input] : [];
|
|
98
95
|
export type TWithUndefined<Input extends string> = Token.TConst<'undefined', Input> extends [infer _0 extends 'undefined', infer Input extends string] ? [S.TWithUndefinedMapping<_0>, Input] : [];
|
|
99
96
|
export type TWithProperty<Input extends string> = (TPropertyKey<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _1, infer Input extends string] ? (TWithValue<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TWithPropertyMapping<_0>, Input] : [];
|
|
100
|
-
export type TWithPropertyList_0<Input extends string, Result extends unknown[] = []> = (
|
|
101
|
-
export type TWithPropertyList<Input extends string> = (
|
|
97
|
+
export type TWithPropertyList_0<Input extends string, Result extends unknown[] = []> = (TPropertyDelimiter<Input> extends [infer _0, infer Input extends string] ? (TWithProperty<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TWithPropertyList_0<Input, [...Result, _0]> : [Result, Input];
|
|
98
|
+
export type TWithPropertyList<Input extends string> = ((TWithProperty<Input> extends [infer _0, infer Input extends string] ? (TWithPropertyList_0<Input> extends [infer _1, infer Input extends string] ? ((TPropertyDelimiter<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TWithPropertyListMapping<_0>, Input] : [];
|
|
102
99
|
export type TWithObject<Input extends string> = (Token.TConst<'{', Input> extends [infer _0, infer Input extends string] ? (TWithPropertyList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'}', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TWithObjectMapping<_0>, Input] : [];
|
|
103
|
-
export type TWithElementList_0<Input extends string, Result extends unknown[] = []> = (
|
|
104
|
-
export type TWithElementList<Input extends string> = (
|
|
100
|
+
export type TWithElementList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TWithValue<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TWithElementList_0<Input, [...Result, _0]> : [Result, Input];
|
|
101
|
+
export type TWithElementList<Input extends string> = ((TWithValue<Input> extends [infer _0, infer Input extends string] ? (TWithElementList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TWithElementListMapping<_0>, Input] : [];
|
|
105
102
|
export type TWithArray<Input extends string> = (Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (TWithElementList<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TWithArrayMapping<_0>, Input] : [];
|
|
106
103
|
export type TWithValue<Input extends string> = (TWithBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithNull<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithUndefined<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithObject<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TWithArray<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TWithValueMapping<_0>, Input] : [];
|
|
107
104
|
export type TPatternBigInt<Input extends string> = Token.TConst<'-?(?:0|[1-9][0-9]*)n', Input> extends [infer _0 extends '-?(?:0|[1-9][0-9]*)n', infer Input extends string] ? [S.TPatternBigIntMapping<_0>, Input] : [];
|
|
@@ -116,8 +113,8 @@ export type TPatternUnion<Input extends string> = ((TPatternTerm<Input> extends
|
|
|
116
113
|
export type TPatternTerm<Input extends string> = (TPatternBase<Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TPatternTermMapping<_0>, Input] : [];
|
|
117
114
|
export type TPatternBody<Input extends string> = (TPatternUnion<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TPatternTerm<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TPatternBodyMapping<_0>, Input] : [];
|
|
118
115
|
export type TPattern<Input extends string> = (Token.TConst<'^', Input> extends [infer _0, infer Input extends string] ? (TPatternBody<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'$', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TPatternMapping<_0>, Input] : [];
|
|
119
|
-
export type TInterfaceDeclarationHeritageList_0<Input extends string, Result extends unknown[] = []> = (
|
|
120
|
-
export type TInterfaceDeclarationHeritageList<Input extends string> = (
|
|
116
|
+
export type TInterfaceDeclarationHeritageList_0<Input extends string, Result extends unknown[] = []> = (Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TInterfaceDeclarationHeritageList_0<Input, [...Result, _0]> : [Result, Input];
|
|
117
|
+
export type TInterfaceDeclarationHeritageList<Input extends string> = ((TType<Input> extends [infer _0, infer Input extends string] ? (TInterfaceDeclarationHeritageList_0<Input> extends [infer _1, infer Input extends string] ? ((Token.TConst<',', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TInterfaceDeclarationHeritageListMapping<_0>, Input] : [];
|
|
121
118
|
export type TInterfaceDeclarationHeritage<Input extends string> = ((Token.TConst<'extends', Input> extends [infer _0, infer Input extends string] ? (TInterfaceDeclarationHeritageList<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [], infer Input extends string] ? [S.TInterfaceDeclarationHeritageMapping<_0>, Input] : [];
|
|
122
119
|
export type TInterfaceDeclarationGeneric<Input extends string> = (Token.TConst<'interface', Input> extends [infer _0, infer Input extends string] ? (Token.TIdent<Input> extends [infer _1, infer Input extends string] ? (TGenericParameters<Input> extends [infer _2, infer Input extends string] ? (TInterfaceDeclarationHeritage<Input> extends [infer _3, infer Input extends string] ? (TProperties<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TInterfaceDeclarationGenericMapping<_0>, Input] : [];
|
|
123
120
|
export type TInterfaceDeclaration<Input extends string> = (Token.TConst<'interface', Input> extends [infer _0, infer Input extends string] ? (Token.TIdent<Input> extends [infer _1, infer Input extends string] ? (TInterfaceDeclarationHeritage<Input> extends [infer _2, infer Input extends string] ? (TProperties<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TInterfaceDeclarationMapping<_0>, Input] : [];
|
|
@@ -125,8 +122,8 @@ export type TTypeAliasDeclarationGeneric<Input extends string> = (Token.TConst<'
|
|
|
125
122
|
export type TTypeAliasDeclaration<Input extends string> = (Token.TConst<'type', Input> extends [infer _0, infer Input extends string] ? (Token.TIdent<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'=', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TTypeAliasDeclarationMapping<_0>, Input] : [];
|
|
126
123
|
export type TExportKeyword<Input extends string> = ((Token.TConst<'export', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown] | [], infer Input extends string] ? [S.TExportKeywordMapping<_0>, Input] : [];
|
|
127
124
|
export type TModuleDeclarationDelimiter<Input extends string> = ((Token.TConst<';', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'\n', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<';', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'\n', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown], infer Input extends string] ? [S.TModuleDeclarationDelimiterMapping<_0>, Input] : [];
|
|
128
|
-
export type TModuleDeclarationList_0<Input extends string, Result extends unknown[] = []> = (
|
|
129
|
-
export type TModuleDeclarationList<Input extends string> = (
|
|
125
|
+
export type TModuleDeclarationList_0<Input extends string, Result extends unknown[] = []> = (TModuleDeclarationDelimiter<Input> extends [infer _0, infer Input extends string] ? (TModuleDeclaration<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? TModuleDeclarationList_0<Input, [...Result, _0]> : [Result, Input];
|
|
126
|
+
export type TModuleDeclarationList<Input extends string> = ((TModuleDeclaration<Input> extends [infer _0, infer Input extends string] ? (TModuleDeclarationList_0<Input> extends [infer _1, infer Input extends string] ? ((TModuleDeclarationDelimiter<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : [[], Input]) extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TModuleDeclarationListMapping<_0>, Input] : [];
|
|
130
127
|
export type TModuleDeclaration<Input extends string> = (TExportKeyword<Input> extends [infer _0, infer Input extends string] ? ((TInterfaceDeclarationGeneric<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TInterfaceDeclaration<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTypeAliasDeclarationGeneric<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTypeAliasDeclaration<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _1, infer Input extends string] ? (TOptionalSemiColon<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown], infer Input extends string] ? [S.TModuleDeclarationMapping<_0>, Input] : [];
|
|
131
128
|
export type TModule<Input extends string> = (TModuleDeclaration<Input> extends [infer _0, infer Input extends string] ? (TModuleDeclarationList<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TModuleMapping<_0>, Input] : [];
|
|
132
129
|
export type TScript<Input extends string> = (TModule<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TType<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TScriptMapping<_0>, Input] : [];
|
|
@@ -197,9 +194,6 @@ export declare const PropertyList: (input: string) => [unknown, string] | [];
|
|
|
197
194
|
export declare const Properties: (input: string) => [unknown, string] | [];
|
|
198
195
|
export declare const _Object_: (input: string) => [unknown, string] | [];
|
|
199
196
|
export declare const ElementNamed: (input: string) => [unknown, string] | [];
|
|
200
|
-
export declare const ElementReadonlyOptional: (input: string) => [unknown, string] | [];
|
|
201
|
-
export declare const ElementReadonly: (input: string) => [unknown, string] | [];
|
|
202
|
-
export declare const ElementOptional: (input: string) => [unknown, string] | [];
|
|
203
197
|
export declare const ElementBase: (input: string) => [unknown, string] | [];
|
|
204
198
|
export declare const Element: (input: string) => [unknown, string] | [];
|
|
205
199
|
export declare const ElementList_0: (input: string, result?: unknown[]) => [unknown[], string];
|
|
@@ -9,11 +9,11 @@ export const GenericParameterExtends = (input) => If(If(Token.Ident(input), ([_0
|
|
|
9
9
|
export const GenericParameterEquals = (input) => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('=', input), ([_1, input]) => If(Type(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.GenericParameterEqualsMapping(_0), input]);
|
|
10
10
|
export const GenericParameterIdentifier = (input) => If(Token.Ident(input), ([_0, input]) => [S.GenericParameterIdentifierMapping(_0), input]);
|
|
11
11
|
export const GenericParameter = (input) => If(If(GenericParameterExtendsEquals(input), ([_0, input]) => [_0, input], () => If(GenericParameterExtends(input), ([_0, input]) => [_0, input], () => If(GenericParameterEquals(input), ([_0, input]) => [_0, input], () => If(GenericParameterIdentifier(input), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.GenericParameterMapping(_0), input]);
|
|
12
|
-
export const GenericParameterList_0 = (input, result = []) => If(If(
|
|
13
|
-
export const GenericParameterList = (input) => If(If(
|
|
12
|
+
export const GenericParameterList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(GenericParameter(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => GenericParameterList_0(input, [...result, _0]), () => [result, input]);
|
|
13
|
+
export const GenericParameterList = (input) => If(If(If(GenericParameter(input), ([_0, input]) => If(GenericParameterList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.GenericParameterListMapping(_0), input]);
|
|
14
14
|
export const GenericParameters = (input) => If(If(Token.Const('<', input), ([_0, input]) => If(GenericParameterList(input), ([_1, input]) => If(Token.Const('>', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.GenericParametersMapping(_0), input]);
|
|
15
|
-
export const GenericCallArgumentList_0 = (input, result = []) => If(If(
|
|
16
|
-
export const GenericCallArgumentList = (input) => If(If(
|
|
15
|
+
export const GenericCallArgumentList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => GenericCallArgumentList_0(input, [...result, _0]), () => [result, input]);
|
|
16
|
+
export const GenericCallArgumentList = (input) => If(If(If(Type(input), ([_0, input]) => If(GenericCallArgumentList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.GenericCallArgumentListMapping(_0), input]);
|
|
17
17
|
export const GenericCallArguments = (input) => If(If(Token.Const('<', input), ([_0, input]) => If(GenericCallArgumentList(input), ([_1, input]) => If(Token.Const('>', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.GenericCallArgumentsMapping(_0), input]);
|
|
18
18
|
export const GenericCall = (input) => If(If(Token.Ident(input), ([_0, input]) => If(GenericCallArguments(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.GenericCallMapping(_0), input]);
|
|
19
19
|
export const OptionalSemiColon = (input) => If(If(If(Token.Const(';', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.OptionalSemiColonMapping(_0), input]);
|
|
@@ -66,18 +66,15 @@ export const Readonly = (input) => If(If(If(Token.Const('readonly', input), ([_0
|
|
|
66
66
|
export const Optional = (input) => If(If(If(Token.Const('?', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.OptionalMapping(_0), input]);
|
|
67
67
|
export const Property = (input) => If(If(Readonly(input), ([_0, input]) => If(PropertyKey(input), ([_1, input]) => If(Optional(input), ([_2, input]) => If(Token.Const(':', input), ([_3, input]) => If(Type(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.PropertyMapping(_0), input]);
|
|
68
68
|
export const PropertyDelimiter = (input) => If(If(If(Token.Const(',', input), ([_0, input]) => If(Token.Const('\n', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const(';', input), ([_0, input]) => If(Token.Const('\n', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If(If(Token.Const(';', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If(If(Token.Const('\n', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => []))))), ([_0, input]) => [S.PropertyDelimiterMapping(_0), input]);
|
|
69
|
-
export const PropertyList_0 = (input, result = []) => If(If(
|
|
70
|
-
export const PropertyList = (input) => If(If(
|
|
69
|
+
export const PropertyList_0 = (input, result = []) => If(If(PropertyDelimiter(input), ([_0, input]) => If(Property(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => PropertyList_0(input, [...result, _0]), () => [result, input]);
|
|
70
|
+
export const PropertyList = (input) => If(If(If(Property(input), ([_0, input]) => If(PropertyList_0(input), ([_1, input]) => If(If(PropertyDelimiter(input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.PropertyListMapping(_0), input]);
|
|
71
71
|
export const Properties = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(PropertyList(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.PropertiesMapping(_0), input]);
|
|
72
72
|
export const _Object_ = (input) => If(Properties(input), ([_0, input]) => [S._Object_Mapping(_0), input]);
|
|
73
73
|
export const ElementNamed = (input) => If(If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => If(Token.Const(':', input), ([_2, input]) => If(Token.Const('readonly', input), ([_3, input]) => If(Type(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Token.Const('readonly', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => If(Token.Const(':', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Type(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.ElementNamedMapping(_0), input]);
|
|
74
|
-
export const
|
|
75
|
-
export const ElementReadonly = (input) => If(If(Token.Const('readonly', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ElementReadonlyMapping(_0), input]);
|
|
76
|
-
export const ElementOptional = (input) => If(If(Type(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ElementOptionalMapping(_0), input]);
|
|
77
|
-
export const ElementBase = (input) => If(If(ElementNamed(input), ([_0, input]) => [_0, input], () => If(ElementReadonlyOptional(input), ([_0, input]) => [_0, input], () => If(ElementReadonly(input), ([_0, input]) => [_0, input], () => If(ElementOptional(input), ([_0, input]) => [_0, input], () => If(Type(input), ([_0, input]) => [_0, input], () => []))))), ([_0, input]) => [S.ElementBaseMapping(_0), input]);
|
|
74
|
+
export const ElementBase = (input) => If(If(ElementNamed(input), ([_0, input]) => [_0, input], () => If(If(Readonly(input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Optional(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ElementBaseMapping(_0), input]);
|
|
78
75
|
export const Element = (input) => If(If(If(Token.Const('...', input), ([_0, input]) => If(ElementBase(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(ElementBase(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ElementMapping(_0), input]);
|
|
79
|
-
export const ElementList_0 = (input, result = []) => If(If(
|
|
80
|
-
export const ElementList = (input) => If(If(
|
|
76
|
+
export const ElementList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(Element(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => ElementList_0(input, [...result, _0]), () => [result, input]);
|
|
77
|
+
export const ElementList = (input) => If(If(If(Element(input), ([_0, input]) => If(ElementList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ElementListMapping(_0), input]);
|
|
81
78
|
export const _Tuple_ = (input) => If(If(Token.Const('[', input), ([_0, input]) => If(ElementList(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S._Tuple_Mapping(_0), input]);
|
|
82
79
|
export const ParameterReadonlyOptional = (input) => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => If(Token.Const(':', input), ([_2, input]) => If(Token.Const('readonly', input), ([_3, input]) => If(Type(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.ParameterReadonlyOptionalMapping(_0), input]);
|
|
83
80
|
export const ParameterReadonly = (input) => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Token.Const('readonly', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [S.ParameterReadonlyMapping(_0), input]);
|
|
@@ -85,8 +82,8 @@ export const ParameterOptional = (input) => If(If(Token.Ident(input), ([_0, inpu
|
|
|
85
82
|
export const ParameterType = (input) => If(If(Token.Ident(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Type(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.ParameterTypeMapping(_0), input]);
|
|
86
83
|
export const ParameterBase = (input) => If(If(ParameterReadonlyOptional(input), ([_0, input]) => [_0, input], () => If(ParameterReadonly(input), ([_0, input]) => [_0, input], () => If(ParameterOptional(input), ([_0, input]) => [_0, input], () => If(ParameterType(input), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.ParameterBaseMapping(_0), input]);
|
|
87
84
|
export const Parameter = (input) => If(If(If(Token.Const('...', input), ([_0, input]) => If(ParameterBase(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(ParameterBase(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ParameterMapping(_0), input]);
|
|
88
|
-
export const ParameterList_0 = (input, result = []) => If(If(
|
|
89
|
-
export const ParameterList = (input) => If(If(
|
|
85
|
+
export const ParameterList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(Parameter(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => ParameterList_0(input, [...result, _0]), () => [result, input]);
|
|
86
|
+
export const ParameterList = (input) => If(If(If(Parameter(input), ([_0, input]) => If(ParameterList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ParameterListMapping(_0), input]);
|
|
90
87
|
export const _Function_ = (input) => If(If(Token.Const('(', input), ([_0, input]) => If(ParameterList(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => If(Token.Const('=>', input), ([_3, input]) => If(Type(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S._Function_Mapping(_0), input]);
|
|
91
88
|
export const _Constructor_ = (input) => If(If(Token.Const('new', input), ([_0, input]) => If(Token.Const('(', input), ([_1, input]) => If(ParameterList(input), ([_2, input]) => If(Token.Const(')', input), ([_3, input]) => If(Token.Const('=>', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [S._Constructor_Mapping(_0), input]);
|
|
92
89
|
export const MappedReadonly = (input) => If(If(If(Token.Const('+', input), ([_0, input]) => If(Token.Const('readonly', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('-', input), ([_0, input]) => If(Token.Const('readonly', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('readonly', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.MappedReadonlyMapping(_0), input]);
|
|
@@ -101,11 +98,11 @@ export const WithString = (input) => If(Token.String(['\"', '\''], input), ([_0,
|
|
|
101
98
|
export const WithNull = (input) => If(Token.Const('null', input), ([_0, input]) => [S.WithNullMapping(_0), input]);
|
|
102
99
|
export const WithUndefined = (input) => If(Token.Const('undefined', input), ([_0, input]) => [S.WithUndefinedMapping(_0), input]);
|
|
103
100
|
export const WithProperty = (input) => If(If(PropertyKey(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(WithValue(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithPropertyMapping(_0), input]);
|
|
104
|
-
export const WithPropertyList_0 = (input, result = []) => If(If(
|
|
105
|
-
export const WithPropertyList = (input) => If(If(
|
|
101
|
+
export const WithPropertyList_0 = (input, result = []) => If(If(PropertyDelimiter(input), ([_0, input]) => If(WithProperty(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => WithPropertyList_0(input, [...result, _0]), () => [result, input]);
|
|
102
|
+
export const WithPropertyList = (input) => If(If(If(WithProperty(input), ([_0, input]) => If(WithPropertyList_0(input), ([_1, input]) => If(If(PropertyDelimiter(input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithPropertyListMapping(_0), input]);
|
|
106
103
|
export const WithObject = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(WithPropertyList(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithObjectMapping(_0), input]);
|
|
107
|
-
export const WithElementList_0 = (input, result = []) => If(If(
|
|
108
|
-
export const WithElementList = (input) => If(If(
|
|
104
|
+
export const WithElementList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(WithValue(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => WithElementList_0(input, [...result, _0]), () => [result, input]);
|
|
105
|
+
export const WithElementList = (input) => If(If(If(WithValue(input), ([_0, input]) => If(WithElementList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithElementListMapping(_0), input]);
|
|
109
106
|
export const WithArray = (input) => If(If(Token.Const('[', input), ([_0, input]) => If(WithElementList(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithArrayMapping(_0), input]);
|
|
110
107
|
export const WithValue = (input) => If(If(WithBigInt(input), ([_0, input]) => [_0, input], () => If(WithNumber(input), ([_0, input]) => [_0, input], () => If(WithBoolean(input), ([_0, input]) => [_0, input], () => If(WithString(input), ([_0, input]) => [_0, input], () => If(WithNull(input), ([_0, input]) => [_0, input], () => If(WithUndefined(input), ([_0, input]) => [_0, input], () => If(WithObject(input), ([_0, input]) => [_0, input], () => If(WithArray(input), ([_0, input]) => [_0, input], () => [])))))))), ([_0, input]) => [S.WithValueMapping(_0), input]);
|
|
111
108
|
export const PatternBigInt = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)n', input), ([_0, input]) => [S.PatternBigIntMapping(_0), input]);
|
|
@@ -120,8 +117,8 @@ export const PatternUnion = (input) => If(If(If(PatternTerm(input), ([_0, input]
|
|
|
120
117
|
export const PatternTerm = (input) => If(If(PatternBase(input), ([_0, input]) => If(PatternBody(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.PatternTermMapping(_0), input]);
|
|
121
118
|
export const PatternBody = (input) => If(If(PatternUnion(input), ([_0, input]) => [_0, input], () => If(PatternTerm(input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.PatternBodyMapping(_0), input]);
|
|
122
119
|
export const Pattern = (input) => If(If(Token.Const('^', input), ([_0, input]) => If(PatternBody(input), ([_1, input]) => If(Token.Const('$', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.PatternMapping(_0), input]);
|
|
123
|
-
export const InterfaceDeclarationHeritageList_0 = (input, result = []) => If(If(
|
|
124
|
-
export const InterfaceDeclarationHeritageList = (input) => If(If(
|
|
120
|
+
export const InterfaceDeclarationHeritageList_0 = (input, result = []) => If(If(Token.Const(',', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => InterfaceDeclarationHeritageList_0(input, [...result, _0]), () => [result, input]);
|
|
121
|
+
export const InterfaceDeclarationHeritageList = (input) => If(If(If(Type(input), ([_0, input]) => If(InterfaceDeclarationHeritageList_0(input), ([_1, input]) => If(If(Token.Const(',', input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.InterfaceDeclarationHeritageListMapping(_0), input]);
|
|
125
122
|
export const InterfaceDeclarationHeritage = (input) => If(If(If(Token.Const('extends', input), ([_0, input]) => If(InterfaceDeclarationHeritageList(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.InterfaceDeclarationHeritageMapping(_0), input]);
|
|
126
123
|
export const InterfaceDeclarationGeneric = (input) => If(If(Token.Const('interface', input), ([_0, input]) => If(Token.Ident(input), ([_1, input]) => If(GenericParameters(input), ([_2, input]) => If(InterfaceDeclarationHeritage(input), ([_3, input]) => If(Properties(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.InterfaceDeclarationGenericMapping(_0), input]);
|
|
127
124
|
export const InterfaceDeclaration = (input) => If(If(Token.Const('interface', input), ([_0, input]) => If(Token.Ident(input), ([_1, input]) => If(InterfaceDeclarationHeritage(input), ([_2, input]) => If(Properties(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [S.InterfaceDeclarationMapping(_0), input]);
|
|
@@ -129,8 +126,8 @@ export const TypeAliasDeclarationGeneric = (input) => If(If(Token.Const('type',
|
|
|
129
126
|
export const TypeAliasDeclaration = (input) => If(If(Token.Const('type', input), ([_0, input]) => If(Token.Ident(input), ([_1, input]) => If(Token.Const('=', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [S.TypeAliasDeclarationMapping(_0), input]);
|
|
130
127
|
export const ExportKeyword = (input) => If(If(If(Token.Const('export', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExportKeywordMapping(_0), input]);
|
|
131
128
|
export const ModuleDeclarationDelimiter = (input) => If(If(If(Token.Const(';', input), ([_0, input]) => If(Token.Const('\n', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const(';', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If(If(Token.Const('\n', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => []))), ([_0, input]) => [S.ModuleDeclarationDelimiterMapping(_0), input]);
|
|
132
|
-
export const ModuleDeclarationList_0 = (input, result = []) => If(If(
|
|
133
|
-
export const ModuleDeclarationList = (input) => If(If(
|
|
129
|
+
export const ModuleDeclarationList_0 = (input, result = []) => If(If(ModuleDeclarationDelimiter(input), ([_0, input]) => If(ModuleDeclaration(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => ModuleDeclarationList_0(input, [...result, _0]), () => [result, input]);
|
|
130
|
+
export const ModuleDeclarationList = (input) => If(If(If(ModuleDeclaration(input), ([_0, input]) => If(ModuleDeclarationList_0(input), ([_1, input]) => If(If(ModuleDeclarationDelimiter(input), ([_0, input]) => [[_0], input], () => [[], input]), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ModuleDeclarationListMapping(_0), input]);
|
|
134
131
|
export const ModuleDeclaration = (input) => If(If(ExportKeyword(input), ([_0, input]) => If(If(InterfaceDeclarationGeneric(input), ([_0, input]) => [_0, input], () => If(InterfaceDeclaration(input), ([_0, input]) => [_0, input], () => If(TypeAliasDeclarationGeneric(input), ([_0, input]) => [_0, input], () => If(TypeAliasDeclaration(input), ([_0, input]) => [_0, input], () => [])))), ([_1, input]) => If(OptionalSemiColon(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.ModuleDeclarationMapping(_0), input]);
|
|
135
132
|
export const Module = (input) => If(If(ModuleDeclaration(input), ([_0, input]) => If(ModuleDeclarationList(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ModuleMapping(_0), input]);
|
|
136
133
|
export const Script = (input) => If(If(Module(input), ([_0, input]) => [_0, input], () => If(GenericType(input), ([_0, input]) => [_0, input], () => If(Type(input), ([_0, input]) => [_0, input], () => []))), ([_0, input]) => [S.ScriptMapping(_0), input]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typebox",
|
|
3
3
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.10",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"jsonschema"
|
|
@@ -16,37 +16,37 @@
|
|
|
16
16
|
"types": "./build/index.d.mts",
|
|
17
17
|
"module": "./build/index.mjs",
|
|
18
18
|
"exports": {
|
|
19
|
+
"./compile": {
|
|
20
|
+
"import": "./build/compile/index.mjs",
|
|
21
|
+
"default": "./build/compile/index.mjs"
|
|
22
|
+
},
|
|
19
23
|
"./error": {
|
|
20
24
|
"import": "./build/error/index.mjs",
|
|
21
25
|
"default": "./build/error/index.mjs"
|
|
22
26
|
},
|
|
23
|
-
"./
|
|
24
|
-
"import": "./build/
|
|
25
|
-
"default": "./build/
|
|
26
|
-
},
|
|
27
|
-
"./system": {
|
|
28
|
-
"import": "./build/system/index.mjs",
|
|
29
|
-
"default": "./build/system/index.mjs"
|
|
27
|
+
"./format": {
|
|
28
|
+
"import": "./build/format/index.mjs",
|
|
29
|
+
"default": "./build/format/index.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./guard": {
|
|
32
32
|
"import": "./build/guard/index.mjs",
|
|
33
33
|
"default": "./build/guard/index.mjs"
|
|
34
34
|
},
|
|
35
|
-
"./
|
|
36
|
-
"import": "./build/
|
|
37
|
-
"default": "./build/
|
|
35
|
+
"./schema": {
|
|
36
|
+
"import": "./build/schema/index.mjs",
|
|
37
|
+
"default": "./build/schema/index.mjs"
|
|
38
38
|
},
|
|
39
|
-
"./
|
|
40
|
-
"import": "./build/
|
|
41
|
-
"default": "./build/
|
|
39
|
+
"./system": {
|
|
40
|
+
"import": "./build/system/index.mjs",
|
|
41
|
+
"default": "./build/system/index.mjs"
|
|
42
42
|
},
|
|
43
43
|
"./type": {
|
|
44
44
|
"import": "./build/type/index.mjs",
|
|
45
45
|
"default": "./build/type/index.mjs"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
48
|
-
"import": "./build/
|
|
49
|
-
"default": "./build/
|
|
47
|
+
"./value": {
|
|
48
|
+
"import": "./build/value/index.mjs",
|
|
49
|
+
"default": "./build/value/index.mjs"
|
|
50
50
|
},
|
|
51
51
|
".": {
|
|
52
52
|
"import": "./build/index.mjs",
|
|
@@ -55,29 +55,29 @@
|
|
|
55
55
|
},
|
|
56
56
|
"typesVersions": {
|
|
57
57
|
"*": {
|
|
58
|
+
"compile": [
|
|
59
|
+
"./build/compile/index.d.mts"
|
|
60
|
+
],
|
|
58
61
|
"error": [
|
|
59
62
|
"./build/error/index.d.mts"
|
|
60
63
|
],
|
|
61
|
-
"
|
|
62
|
-
"./build/
|
|
63
|
-
],
|
|
64
|
-
"system": [
|
|
65
|
-
"./build/system/index.d.mts"
|
|
64
|
+
"format": [
|
|
65
|
+
"./build/format/index.d.mts"
|
|
66
66
|
],
|
|
67
67
|
"guard": [
|
|
68
68
|
"./build/guard/index.d.mts"
|
|
69
69
|
],
|
|
70
|
-
"
|
|
71
|
-
"./build/
|
|
70
|
+
"schema": [
|
|
71
|
+
"./build/schema/index.d.mts"
|
|
72
72
|
],
|
|
73
|
-
"
|
|
74
|
-
"./build/
|
|
73
|
+
"system": [
|
|
74
|
+
"./build/system/index.d.mts"
|
|
75
75
|
],
|
|
76
76
|
"type": [
|
|
77
77
|
"./build/type/index.d.mts"
|
|
78
78
|
],
|
|
79
|
-
"
|
|
80
|
-
"./build/
|
|
79
|
+
"value": [
|
|
80
|
+
"./build/value/index.d.mts"
|
|
81
81
|
],
|
|
82
82
|
".": [
|
|
83
83
|
"./build/index.d.mts"
|
package/readme.md
CHANGED
|
@@ -111,7 +111,7 @@ type User = Type.Static<typeof User> // type User = {
|
|
|
111
111
|
|
|
112
112
|
## Script
|
|
113
113
|
|
|
114
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/
|
|
114
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFkBDGAC0YgBMBXAG1WoBjCADsAzvGZs4AXkREAdAGVBUYGBgAKAAaU4cQmjgA1VIJjQALLLgBvOGQBccEdxDFUUADRwkz1+6ePgBe-m4e3nAA7mGBUHAAvnoGRCZmFlAAzDb2Ti7hQb6xESHFnonJhuim5tAATDkOZZF++XEV2gCU1HRwAOJQTGCswIJiHDz8QqIS-YPDo+NyyGjKqupaUqw+uvpVabCoZDnJ+pBiwDDAos41GZZepy7QIEy8t+nQmY-6+twAbh9alA6skkntUn1UDhUDAoEgTr84P9PFdBKgxB9DmQANoAXR+v2AIk4owxzXxYMqqSknmAb0RvyY7mAqBEMCB90J+lJGAw3DEqE5Vm5cDEaEEfCYUGFUEsVIhRgYGPYclsTwA5tCQLD4c4oTC4UhRa8YHS3s5aWo3lSutR9sqxKr5KslDAWKMADxVCAYOZDEZjHF4R2sPB4gB8+l6DpVjKRCcTSeTKZTvX0WsNerscAUecSotTReLJfTcFN5veObzCgqJfrDeTvQSQA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFkBDGAC0YgBMBXAG1WoBjCADsAzvABqqQTGgAWOAF5ERAHQB5YgCsZMABQBvOGQBcqtGoBy3EMVRR9ASgA0cJOeSWbdh87cAXp7qPvaOrnAA7sHetmHOcAC+TpTC4lJ60ADMyhaomjp6RiYx+aF+ER551nEVgaU1vuFJKWkScNKy0ABMuV75WrqyxWbV5eFuVf2N8U4t1HRwAOJQTGCswIJiHDz8QqLt0rCoZH3qg0WGlHBwkGLAMMCi5p1yUPIu13Ai0CBMvC9MlAsp8btwAG6ArpQbqUZKpA7wJaoHCoGBQJBnSwXYZXG7ghyPQSoMQNACCUFWSH0RxgJ1cX2AIk4mxJ5MpTGp03GzhS8La8GYdKgwH+WIGhVxXyYdmAqBEMChbw+XxZGAw3DEqCVClBcDEaEEfCYUB170+-MRjBJ7BU0xxBjxcAA5iiQGiMeZkaj0Ug9X9haKAYwWA4g3CUpRCGhrWJbdUAMowFibAA80ZRGFjrAAfDd8wXC4sM9nck7CxXK1XqzX84sbq6fZ64MY1G2knra13u1363AA2H-uZW+3El8exPJ3X6IkgA)
|
|
115
115
|
|
|
116
116
|
TypeBox includes a runtime TypeScript engine that can transform TypeScript definitions to JSON Schema. The engine is fully type-safe and supports many programmable constructs including Conditional, Mapped, Indexed, Generics, Distributive Generics, and more.
|
|
117
117
|
|
|
@@ -120,45 +120,43 @@ TypeBox includes a runtime TypeScript engine that can transform TypeScript defin
|
|
|
120
120
|
Syntax highlighting is available via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sinclairzx81.typebox-script)
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
import Type from 'typebox'
|
|
124
|
+
|
|
125
|
+
// Math Module
|
|
126
|
+
|
|
127
|
+
const Math = Type.Script(`
|
|
128
|
+
type Vector4 = { x: number, y: number, z: number, w: number }
|
|
129
|
+
type Vector3 = { x: number, y: number, z: number }
|
|
130
|
+
type Vector2 = { x: number, y: number }
|
|
131
|
+
`)
|
|
132
|
+
|
|
133
|
+
// Graphics Module
|
|
134
|
+
|
|
135
|
+
const Graphics = Type.Script(Math, `
|
|
136
|
+
type Vertex = {
|
|
137
|
+
position: Vector4,
|
|
138
|
+
normal: Vector3,
|
|
139
|
+
uv: Vector2
|
|
140
|
+
}
|
|
141
|
+
type Geometry = {
|
|
142
|
+
vertices: Vertex[],
|
|
143
|
+
indices: number[]
|
|
128
144
|
}
|
|
129
|
-
type
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
145
|
+
type Material = {
|
|
146
|
+
ambient: Vector4,
|
|
147
|
+
diffuse: Vector4,
|
|
148
|
+
specular: Vector4
|
|
133
149
|
}
|
|
134
|
-
type
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
body: string,
|
|
138
|
-
author: User,
|
|
139
|
-
comments: Comment[]
|
|
150
|
+
type Mesh = {
|
|
151
|
+
geometry: Geometry,
|
|
152
|
+
material: Material
|
|
140
153
|
}
|
|
141
154
|
`)
|
|
142
155
|
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Post.properties.author.properties.name
|
|
148
|
-
Post.properties.comments.items.properties.text
|
|
149
|
-
Post.properties.comments.items.properties.author.properties.id
|
|
150
|
-
Post.properties.comments.items.properties.author.properties.name
|
|
151
|
-
|
|
152
|
-
// Inference
|
|
153
|
-
function present(post: Type.Static<typeof Post>) {
|
|
154
|
-
post.id
|
|
155
|
-
post.title
|
|
156
|
-
post.author.id
|
|
157
|
-
post.author.name
|
|
158
|
-
post.comments[0].text
|
|
159
|
-
post.comments[0].author.id
|
|
160
|
-
post.comments[0].author.name
|
|
161
|
-
}
|
|
156
|
+
type Mesh = Type.Static<typeof Graphics['Mesh']> // type Mesh = {
|
|
157
|
+
// geometry: { ... },
|
|
158
|
+
// material: { ... }
|
|
159
|
+
// }
|
|
162
160
|
```
|
|
163
161
|
|
|
164
162
|
<a name="Schema"></a>
|
|
@@ -177,18 +175,21 @@ import Schema from 'typebox/schema'
|
|
|
177
175
|
|
|
178
176
|
### Compile
|
|
179
177
|
|
|
180
|
-
The compiler accepts
|
|
178
|
+
The compiler accepts either TypeBox types or native JSON Schema.
|
|
181
179
|
|
|
182
180
|
```typescript
|
|
183
|
-
|
|
181
|
+
|
|
182
|
+
// Type
|
|
183
|
+
|
|
184
|
+
const VectorA = Schema.Compile(Type.Object({ // const VectorA: Validator<TObject<{
|
|
184
185
|
x: Type.Number(), // x: TNumber
|
|
185
186
|
y: Type.Number(), // y: TNumber
|
|
186
187
|
z: Type.Number() // z: TNumber
|
|
187
188
|
})) // }>>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
189
|
+
|
|
190
|
+
// Schema
|
|
191
|
+
|
|
192
|
+
const VectorB = Schema.Compile({ // const VectorB: Validator<{
|
|
192
193
|
type: 'object', // type: "object";
|
|
193
194
|
required: ['x', 'y', 'z'], // required: ["x", "y", "z"];
|
|
194
195
|
properties: { // properties: { ... };
|
|
@@ -201,29 +202,30 @@ const Vector = Schema.Compile({ // const Vector: Validator<{
|
|
|
201
202
|
|
|
202
203
|
### Validate
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
Compiled validator instances provide functions to Check and Parse values.
|
|
205
206
|
|
|
206
207
|
```typescript
|
|
208
|
+
|
|
209
|
+
// Compile
|
|
210
|
+
|
|
207
211
|
const Vector = Schema.Compile(Type.Script(`{
|
|
208
212
|
x: number
|
|
209
213
|
y: number
|
|
210
214
|
z: number
|
|
211
215
|
}`))
|
|
212
216
|
|
|
213
|
-
|
|
214
|
-
x: 1,
|
|
215
|
-
y: 0,
|
|
216
|
-
z: 0
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
const value = Vector.Parse({ // const value: {
|
|
220
|
-
x: 1, // x: number
|
|
221
|
-
y: 0, // y: number
|
|
222
|
-
z: 0 // z: number
|
|
223
|
-
}) // }
|
|
224
|
-
```
|
|
217
|
+
// Check
|
|
225
218
|
|
|
219
|
+
const valid = Vector.Check({ x: 1, y: 0, z: 0 }) // const valid: boolean
|
|
226
220
|
|
|
221
|
+
// Parse
|
|
222
|
+
|
|
223
|
+
const result = Vector.Parse({ x: 1, y: 0, z: 0 }) // const result: {
|
|
224
|
+
// x: number
|
|
225
|
+
// y: number
|
|
226
|
+
// z: number
|
|
227
|
+
// }
|
|
228
|
+
```
|
|
227
229
|
|
|
228
230
|
### Coverage
|
|
229
231
|
|