typebox 1.2.1 → 1.2.3
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/type/action/conditional.d.mts +2 -3
- package/build/type/action/conditional.mjs +2 -1
- package/build/type/action/mapped.d.mts +2 -3
- package/build/type/action/mapped.mjs +2 -1
- package/build/type/engine/call/instantiate.d.mts +1 -3
- package/build/type/engine/call/instantiate.mjs +3 -2
- package/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/build/type/engine/instantiate.d.mts +5 -5
- package/build/type/engine/instantiate.mjs +4 -1
- package/build/type/engine/interface/instantiate.d.mts +3 -6
- package/build/type/engine/module/instantiate.d.mts +1 -3
- package/build/type/engine/module/instantiate.mjs +2 -1
- package/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/build/type/engine/parameters/instantiate.mjs +2 -1
- package/build/type/engine/ref/instantiate.d.mts +3 -3
- package/build/type/engine/ref/instantiate.mjs +6 -6
- package/build/type/extends/tuple.d.mts +3 -6
- package/build/type/extends/tuple.mjs +3 -2
- package/build/type/script/mapping.d.mts +16 -20
- package/build/type/script/mapping.mjs +17 -23
- package/build/type/script/parser.d.mts +9 -13
- package/build/type/script/parser.mjs +5 -7
- package/build/type/script/script.d.mts +3 -4
- package/build/type/script/script.mjs +3 -2
- package/build/type/types/call.d.mts +3 -3
- package/build/type/types/call.mjs +3 -2
- package/package.json +1 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../types/schema.mjs';
|
|
2
2
|
import { type TDeferred } from '../types/deferred.mjs';
|
|
3
3
|
import { type TConditionalAction } from '../engine/conditional/instantiate.mjs';
|
|
4
|
+
import { type TState } from '../engine/instantiate.mjs';
|
|
4
5
|
/** Creates a deferred Conditional action. */
|
|
5
6
|
export type TConditionalDeferred<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TDeferred<'Conditional', [Left, Right, True, False]>);
|
|
6
7
|
/** Creates a deferred Conditional action. */
|
|
7
8
|
export declare function ConditionalDeferred<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema>(left: Left, right: Right, true_: True, false_: False, options?: TSchemaOptions): TConditionalDeferred<Left, Right, True, False>;
|
|
8
9
|
/** Applies a Conditional action to the given types. */
|
|
9
|
-
export type TConditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TConditionalAction<{},
|
|
10
|
-
callstack: [];
|
|
11
|
-
}, Left, Right, True, False>);
|
|
10
|
+
export type TConditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TConditionalAction<{}, TState<[], []>, Left, Right, True, False>);
|
|
12
11
|
/** Applies a Conditional action to the given types. */
|
|
13
12
|
export declare function Conditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema>(left: Left, right: Right, true_: True, false_: False, options?: TSchemaOptions): TConditional<Left, Right, True, False>;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Deferred } from '../types/deferred.mjs';
|
|
4
4
|
import { ConditionalAction } from '../engine/conditional/instantiate.mjs';
|
|
5
|
+
import { State } from '../engine/instantiate.mjs';
|
|
5
6
|
/** Creates a deferred Conditional action. */
|
|
6
7
|
export function ConditionalDeferred(left, right, true_, false_, options = {}) {
|
|
7
8
|
return Deferred('Conditional', [left, right, true_, false_], options);
|
|
8
9
|
}
|
|
9
10
|
/** Applies a Conditional action to the given types. */
|
|
10
11
|
export function Conditional(left, right, true_, false_, options = {}) {
|
|
11
|
-
return ConditionalAction({},
|
|
12
|
+
return ConditionalAction({}, State([], []), left, right, true_, false_, options);
|
|
12
13
|
}
|
|
@@ -2,13 +2,12 @@ import { type TSchema, type TSchemaOptions } from '../types/schema.mjs';
|
|
|
2
2
|
import { type TIdentifier } from '../types/identifier.mjs';
|
|
3
3
|
import { type TDeferred } from '../types/deferred.mjs';
|
|
4
4
|
import { type TMappedAction } from '../engine/mapped/instantiate.mjs';
|
|
5
|
+
import { type TState } from '../engine/instantiate.mjs';
|
|
5
6
|
/** Creates a deferred Mapped action. */
|
|
6
7
|
export type TMappedDeferred<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TDeferred<'Mapped', [Identifier, Type, As, Property]>);
|
|
7
8
|
/** Creates a deferred Mapped action. */
|
|
8
9
|
export declare function MappedDeferred<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema>(identifier: Identifier, type: Type, as: As, property: Property, options?: TSchemaOptions): TMappedDeferred<Identifier, Type, As, Property>;
|
|
9
10
|
/** Applies a Mapped action using the given types. */
|
|
10
|
-
export type TMapped<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TMappedAction<{},
|
|
11
|
-
callstack: [];
|
|
12
|
-
}, Identifier, Type, As, Property>);
|
|
11
|
+
export type TMapped<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TMappedAction<{}, TState<[], []>, Identifier, Type, As, Property>);
|
|
13
12
|
/** Applies a Mapped action using the given types. */
|
|
14
13
|
export declare function Mapped<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema>(identifier: Identifier, type: Type, as: As, property: Property, options?: TSchemaOptions): TMapped<Identifier, Type, As, Property>;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Deferred } from '../types/deferred.mjs';
|
|
4
4
|
import { MappedAction } from '../engine/mapped/instantiate.mjs';
|
|
5
|
+
import { State } from '../engine/instantiate.mjs';
|
|
5
6
|
/** Creates a deferred Mapped action. */
|
|
6
7
|
export function MappedDeferred(identifier, type, as, property, options = {}) {
|
|
7
8
|
return Deferred('Mapped', [identifier, type, as, property], options);
|
|
8
9
|
}
|
|
9
10
|
/** Applies a Mapped action using the given types. */
|
|
10
11
|
export function Mapped(identifier, type, as, property, options = {}) {
|
|
11
|
-
return MappedAction({},
|
|
12
|
+
return MappedAction({}, State([], []), identifier, type, as, property, options);
|
|
12
13
|
}
|
|
@@ -13,9 +13,7 @@ import { type TResolveTarget } from './resolve_target.mjs';
|
|
|
13
13
|
import { type TResolveArgumentsContext } from './resolve_arguments.mjs';
|
|
14
14
|
type TPeek<State extends TState, Result extends string = State['callstack'] extends [...infer _ extends string[], infer Top extends string] ? Top : ''> = Result;
|
|
15
15
|
type TIsTailCall<State extends TState, Name extends string, Result extends boolean = TPeek<State> extends Name ? true : false> = Result;
|
|
16
|
-
type TCallDispatch<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, Arguments extends TSchema[], ArgumentsContext extends TProperties = TResolveArgumentsContext<Context, State, Parameters, Arguments>, ReturnType extends TSchema = TInstantiateType<ArgumentsContext,
|
|
17
|
-
callstack: [...State['callstack'], Target['$ref']];
|
|
18
|
-
}, Expression>> = TInstantiateType<Context, State, ReturnType>;
|
|
16
|
+
type TCallDispatch<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, Arguments extends TSchema[], ArgumentsContext extends TProperties = TResolveArgumentsContext<Context, State, Parameters, Arguments>, ReturnType extends TSchema = TInstantiateType<ArgumentsContext, TState<[...State['callstack'], Target['$ref']], State['visited']>, Expression>> = TInstantiateType<ArgumentsContext, TState<[], []>, ReturnType>;
|
|
19
17
|
type TCallDistributed<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, DistributedArguments extends TSchema[][], Result extends TSchema[] = []> = (DistributedArguments extends [infer Arguments extends TSchema[], ...infer DistributedArguments extends TSchema[][]] ? TCallDispatch<Context, State, Target, Parameters, Expression, Arguments> extends infer ReturnType extends TSchema ? TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments, [...Result, ReturnType]> : never : Result);
|
|
20
18
|
type TCallImmediate<Context extends TProperties, State extends TState, Target extends TRef, Parameters extends TParameter[], Expression extends TSchema, InstantiatedArguments extends TSchema[], DistributedArguments extends TSchema[][] = TDistributeArguments<Parameters, InstantiatedArguments, Expression>, ReturnTypes extends TSchema[] = TCallDistributed<Context, State, Target, Parameters, Expression, DistributedArguments>, Result extends TSchema = ReturnTypes['length'] extends 1 ? ReturnTypes[0] : TEvaluateUnion<ReturnTypes>> = Result;
|
|
21
19
|
export type TCallInstantiate<Context extends TProperties, State extends TState, Target extends TSchema, Arguments extends TSchema[], InstantiatedArguments extends TSchema[] = TInstantiateTypes<Context, State, Arguments>, Resolved extends [string, TSchema] = TResolveTarget<Context, Target, Arguments>, Name extends string = Resolved[0], Type extends TSchema = Resolved[1], Result extends TSchema = (Type extends TGeneric<infer Parameters extends TParameter[], infer Expression extends TSchema> ? TIsTailCall<State, Name> extends true ? TCallConstruct<TRef<Name>, InstantiatedArguments> : TCallImmediate<Context, State, TRef<Name>, Parameters, Expression, InstantiatedArguments> : TCallConstruct<Target, InstantiatedArguments>)> = Result;
|
|
@@ -6,6 +6,7 @@ import { IsGeneric } from '../../types/generic.mjs';
|
|
|
6
6
|
import { EvaluateUnion } from '../evaluate/index.mjs';
|
|
7
7
|
import { InstantiateType } from '../instantiate.mjs';
|
|
8
8
|
import { InstantiateTypes } from '../instantiate.mjs';
|
|
9
|
+
import { State } from '../instantiate.mjs';
|
|
9
10
|
// ------------------------------------------------------------------
|
|
10
11
|
// Infrastructure
|
|
11
12
|
// ------------------------------------------------------------------
|
|
@@ -22,8 +23,8 @@ function IsTailCall(state, name) {
|
|
|
22
23
|
}
|
|
23
24
|
function CallDispatch(context, state, target, parameters, expression, arguments_) {
|
|
24
25
|
const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
|
|
25
|
-
const returnType = InstantiateType(argumentsContext,
|
|
26
|
-
return InstantiateType(
|
|
26
|
+
const returnType = InstantiateType(argumentsContext, State([...state['callstack'], target['$ref']], state['visited']), expression);
|
|
27
|
+
return InstantiateType(argumentsContext, State([], []), returnType);
|
|
27
28
|
}
|
|
28
29
|
function CallDistributed(context, state, target, parameters, expression, distributedArguments) {
|
|
29
30
|
return distributedArguments.reduce((result, arguments_) => [...result, CallDispatch(context, state, target, parameters, expression, arguments_)], []);
|
|
@@ -3,11 +3,10 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TConstructor } from '../../types/constructor.mjs';
|
|
4
4
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
5
5
|
import { type TConstructorParametersDeferred } from '../../action/constructor_parameters.mjs';
|
|
6
|
-
import { type
|
|
6
|
+
import { type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { type TInstantiateElements } from '../instantiate.mjs';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
8
|
+
import { type TState } from '../instantiate.mjs';
|
|
9
|
+
type TConstructorParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TConstructor ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, TState<[], []>, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
11
10
|
export type TConstructorParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TConstructorParametersOperation<Type> : TConstructorParametersDeferred<Type>> = Result;
|
|
12
11
|
export declare function ConstructorParametersAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TConstructorParametersAction<Type>;
|
|
13
12
|
export type TConstructorParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TConstructorParametersAction<InstantiatedType>;
|
|
@@ -6,9 +6,10 @@ import { Tuple } from '../../types/tuple.mjs';
|
|
|
6
6
|
import { ConstructorParametersDeferred } from '../../action/constructor_parameters.mjs';
|
|
7
7
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
8
8
|
import { InstantiateElements } from '../instantiate.mjs';
|
|
9
|
+
import { State } from '../instantiate.mjs';
|
|
9
10
|
function ConstructorParametersOperation(type) {
|
|
10
11
|
const parameters = IsConstructor(type) ? type['parameters'] : [];
|
|
11
|
-
const instantiatedParameters = InstantiateElements({},
|
|
12
|
+
const instantiatedParameters = InstantiateElements({}, State([], []), parameters);
|
|
12
13
|
const result = Tuple(instantiatedParameters);
|
|
13
14
|
return result;
|
|
14
15
|
}
|
|
@@ -6,12 +6,9 @@ import { type TCyclicDependencies } from '../cyclic/dependencies.mjs';
|
|
|
6
6
|
import { type TInterfaceDeferred } from '../../action/index.mjs';
|
|
7
7
|
import { type TInstantiateProperties } from '../instantiate.mjs';
|
|
8
8
|
import { type TInstantiateTypes } from '../instantiate.mjs';
|
|
9
|
+
import { type TState } from '../instantiate.mjs';
|
|
9
10
|
import { type TEvaluateIntersect } from '../evaluate/evaluate.mjs';
|
|
10
|
-
type TCyclicInterface<Context extends TProperties, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, {
|
|
11
|
-
callstack: [];
|
|
12
|
-
}, Heritage>, instantiatedProperties extends TProperties = TInstantiateProperties<{}, {
|
|
13
|
-
callstack: [];
|
|
14
|
-
}, Properties>, EvaluatedInterface extends TSchema = TEvaluateIntersect<[...InstantiatedHeritage, TObject<instantiatedProperties>]>> = EvaluatedInterface;
|
|
11
|
+
type TCyclicInterface<Context extends TProperties, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, TState<[], []>, Heritage>, instantiatedProperties extends TProperties = TInstantiateProperties<{}, TState<[], []>, Properties>, EvaluatedInterface extends TSchema = TEvaluateIntersect<[...InstantiatedHeritage, TObject<instantiatedProperties>]>> = EvaluatedInterface;
|
|
15
12
|
type TCyclicDefinitions<Context extends TProperties, Dependencies extends string[], Result extends TProperties = {
|
|
16
13
|
[Key in Extract<keyof Context, Dependencies[number]>]: Context[Key] extends TInterfaceDeferred<infer Heritage extends TSchema[], infer Properties extends TProperties> ? TCyclicInterface<Context, Heritage, Properties> : Context[Key];
|
|
17
14
|
}> = Result;
|
|
@@ -7,10 +7,11 @@ import { CyclicDependencies } from '../cyclic/dependencies.mjs';
|
|
|
7
7
|
import { IsInterfaceDeferred } from '../../action/index.mjs';
|
|
8
8
|
import { InstantiateProperties } from '../instantiate.mjs';
|
|
9
9
|
import { InstantiateTypes } from '../instantiate.mjs';
|
|
10
|
+
import { State } from '../instantiate.mjs';
|
|
10
11
|
import { EvaluateIntersect } from '../evaluate/evaluate.mjs';
|
|
11
12
|
function CyclicInterface(context, heritage, properties) {
|
|
12
|
-
const instantiatedHeritage = InstantiateTypes(context,
|
|
13
|
-
const instantiatedProperties = InstantiateProperties({},
|
|
13
|
+
const instantiatedHeritage = InstantiateTypes(context, State([], []), heritage);
|
|
14
|
+
const instantiatedProperties = InstantiateProperties({}, State([], []), properties);
|
|
14
15
|
const evaluatedInterface = EvaluateIntersect([...instantiatedHeritage, Object(instantiatedProperties)]);
|
|
15
16
|
return evaluatedInterface;
|
|
16
17
|
}
|
|
@@ -52,9 +52,11 @@ import { type TUncapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
|
52
52
|
import { type TUppercaseInstantiate } from './intrinsics/instantiate.mjs';
|
|
53
53
|
import { type TWithInstantiate } from './with/instantiate.mjs';
|
|
54
54
|
import { type TRestSpread } from './rest/index.mjs';
|
|
55
|
-
export interface TState {
|
|
56
|
-
callstack:
|
|
55
|
+
export interface TState<CallStack extends string[] = string[], Visited extends string[] = string[]> {
|
|
56
|
+
callstack: CallStack;
|
|
57
|
+
visited: Visited;
|
|
57
58
|
}
|
|
59
|
+
export declare function State<CallStack extends string[], Visited extends string[]>(callstack: CallStack, visited: Visited): TState<CallStack, Visited>;
|
|
58
60
|
export type TCanInstantiate<Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef ? false : TCanInstantiate<Right> : true;
|
|
59
61
|
export declare function CanInstantiate<Types extends TSchema[]>(types: [...Types]): TCanInstantiate<Types>;
|
|
60
62
|
type ModifierAction = 'add' | 'remove' | 'none';
|
|
@@ -158,9 +160,7 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
158
160
|
export type TInstantiateType<Context extends TProperties, State extends TState, Input extends TSchema, Immutable extends boolean = Input extends TImmutable ? true : false, Modifiers extends [TSchema, ModifierAction, ModifierAction] = TModifierActions<Input, Input extends TReadonly<Input> ? 'add' : 'none', Input extends TOptional<Input> ? 'add' : 'none'>, Type extends TSchema = Modifiers[0], Instantiated extends TSchema = (Type extends TRef<infer Ref extends string> ? TRefInstantiate<Context, State, Type, Ref> : Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> : Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, InstanceType>> : Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State, ReturnType>> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TDependent<TInstantiateType<Context, State, If>, TInstantiateType<Context, State, Then>, TInstantiateType<Context, State, Else>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TInstantiateType<Context, State, Type>> : Type extends TRecord<infer Key extends string, infer Type extends TSchema> ? TRecord<Key, TInstantiateType<Context, State, Type>> : Type extends TRest<infer Type extends TSchema> ? TRest<TInstantiateType<Context, State, Type>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TInstantiateElements<Context, State, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TInstantiateTypes<Context, State, Types>> : Type), WithImmutable extends TSchema = Immutable extends true ? TImmutable<Instantiated> : Instantiated, WithModifiers extends TSchema = TApplyReadonly<Modifiers[1], TApplyOptional<Modifiers[2], WithImmutable>>> = WithModifiers;
|
|
159
161
|
export declare function InstantiateType<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, input: Type): TInstantiateType<Context, State, Type>;
|
|
160
162
|
/** Instantiates computed schematics using the given context and type. */
|
|
161
|
-
export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context,
|
|
162
|
-
callstack: [];
|
|
163
|
-
}, Type>);
|
|
163
|
+
export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, TState<[], []>, Type>);
|
|
164
164
|
/** Instantiates computed schematics using the given context and type. */
|
|
165
165
|
export declare function Instantiate<Context extends TProperties, Type extends TSchema>(context: Context, type: Type): TInstantiate<Context, Type>;
|
|
166
166
|
export {};
|
|
@@ -65,6 +65,9 @@ import { UncapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
|
65
65
|
import { UppercaseInstantiate } from './intrinsics/instantiate.mjs';
|
|
66
66
|
import { WithInstantiate } from './with/instantiate.mjs';
|
|
67
67
|
import { RestSpread } from './rest/index.mjs';
|
|
68
|
+
export function State(callstack, visited) {
|
|
69
|
+
return { callstack, visited };
|
|
70
|
+
}
|
|
68
71
|
export function CanInstantiate(types) {
|
|
69
72
|
return Guard.TakeLeft(types, (left, right) => IsRef(left)
|
|
70
73
|
? false
|
|
@@ -157,5 +160,5 @@ export function InstantiateType(context, state, input) {
|
|
|
157
160
|
}
|
|
158
161
|
/** Instantiates computed schematics using the given context and type. */
|
|
159
162
|
export function Instantiate(context, type) {
|
|
160
|
-
return InstantiateType(context,
|
|
163
|
+
return InstantiateType(context, State([], []), type);
|
|
161
164
|
}
|
|
@@ -3,16 +3,13 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TObject } from '../../types/object.mjs';
|
|
4
4
|
import { type TEvaluateIntersect } from '../evaluate/evaluate.mjs';
|
|
5
5
|
import { type TInterfaceDeferred } from '../../action/index.mjs';
|
|
6
|
-
import { type
|
|
6
|
+
import { type TCanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { type TInstantiateProperties } from '../instantiate.mjs';
|
|
8
8
|
import { type TInstantiateTypes } from '../instantiate.mjs';
|
|
9
|
+
import { type TState } from '../instantiate.mjs';
|
|
9
10
|
type TInterfaceOperation<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TEvaluateIntersect<[...Heritage, TObject<Properties>]>> = Result;
|
|
10
11
|
export type TInterfaceAction<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TCanInstantiate<Heritage> extends true ? TInterfaceOperation<Heritage, Properties> : TInterfaceDeferred<Heritage, Properties>> = Result;
|
|
11
12
|
export declare function InterfaceAction<Heritage extends TSchema[], Properties extends TProperties>(heritage: [...Heritage], properties: Properties, options: TSchemaOptions): TInterfaceAction<Heritage, Properties>;
|
|
12
|
-
export type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context,
|
|
13
|
-
callstack: [];
|
|
14
|
-
}, Heritage>, InstantiatedProperties extends TProperties = TInstantiateProperties<Context, {
|
|
15
|
-
callstack: [];
|
|
16
|
-
}, Properties>> = TInterfaceAction<InstantiatedHeritage, InstantiatedProperties>;
|
|
13
|
+
export type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, State, Heritage>, InstantiatedProperties extends TProperties = TInstantiateProperties<Context, State, Properties>> = TInterfaceAction<InstantiatedHeritage, InstantiatedProperties>;
|
|
17
14
|
export declare function InterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties>(context: Context, state: State, heritage: [...Heritage], properties: Properties, options: TSchemaOptions): TInterfaceInstantiate<Context, State, Heritage, Properties>;
|
|
18
15
|
export {};
|
|
@@ -9,9 +9,7 @@ type TInstantiateCyclics<Context extends TProperties, CyclicKeys extends string[
|
|
|
9
9
|
[Key in Extract<keyof Context, CyclicKeys[number]>]: TInstantiateCyclic<Context, Key, Context[Key]>;
|
|
10
10
|
}> = Result;
|
|
11
11
|
type TInstantiateNonCyclics<Context extends TProperties, CyclicKeys extends string[], Result extends TProperties = {
|
|
12
|
-
[Key in Exclude<keyof Context, CyclicKeys[number]>]: TInstantiateType<Context,
|
|
13
|
-
callstack: [];
|
|
14
|
-
}, Context[Key]>;
|
|
12
|
+
[Key in Exclude<keyof Context, CyclicKeys[number]>]: TInstantiateType<Context, TState<[], []>, Context[Key]>;
|
|
15
13
|
}> = Result;
|
|
16
14
|
type TInstantiateModule<Context extends TProperties, CyclicCandidates extends string[] = TCyclicCandidates<Context>, InstantiatedCyclics extends TProperties = TInstantiateCyclics<Context, CyclicCandidates>, InstantiatedNonCyclics extends TProperties = TInstantiateNonCyclics<Context, CyclicCandidates>, InstantiatedModule extends TProperties = InstantiatedCyclics & InstantiatedNonCyclics> = {
|
|
17
15
|
[Key in keyof InstantiatedModule]: InstantiatedModule[Key];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
3
|
import { Guard } from '../../../guard/index.mjs';
|
|
4
4
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
5
|
+
import { State } from '../instantiate.mjs';
|
|
5
6
|
// ------------------------------------------------------------------
|
|
6
7
|
// Module: Instantiation Infrastructure
|
|
7
8
|
// ------------------------------------------------------------------
|
|
@@ -17,7 +18,7 @@ function InstantiateCyclics(context, cyclicKeys) {
|
|
|
17
18
|
function InstantiateNonCyclics(context, cyclicKeys) {
|
|
18
19
|
const keys = Guard.Keys(context).filter(key => !cyclicKeys.includes(key));
|
|
19
20
|
return keys.reduce((result, key) => {
|
|
20
|
-
return { ...result, [key]: InstantiateType(context,
|
|
21
|
+
return { ...result, [key]: InstantiateType(context, State([], []), context[key]) };
|
|
21
22
|
}, {});
|
|
22
23
|
}
|
|
23
24
|
function InstantiateModule(context, options) {
|
|
@@ -3,11 +3,10 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
3
3
|
import { type TFunction } from '../../types/function.mjs';
|
|
4
4
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
5
5
|
import { type TParametersDeferred } from '../../action/parameters.mjs';
|
|
6
|
-
import { type
|
|
6
|
+
import { type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
7
7
|
import { type TInstantiateElements } from '../instantiate.mjs';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
8
|
+
import { type TState } from '../instantiate.mjs';
|
|
9
|
+
type TParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TFunction ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, TState<[], []>, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result;
|
|
11
10
|
export type TParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TParametersOperation<Type> : TParametersDeferred<Type>> = Result;
|
|
12
11
|
export declare function ParametersAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TParametersAction<Type>;
|
|
13
12
|
export type TParametersInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TParametersAction<InstantiatedType>;
|
|
@@ -6,9 +6,10 @@ import { Tuple } from '../../types/tuple.mjs';
|
|
|
6
6
|
import { ParametersDeferred } from '../../action/parameters.mjs';
|
|
7
7
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
8
8
|
import { InstantiateElements } from '../instantiate.mjs';
|
|
9
|
+
import { State } from '../instantiate.mjs';
|
|
9
10
|
function ParametersOperation(type) {
|
|
10
11
|
const parameters = IsFunction(type) ? type['parameters'] : [];
|
|
11
|
-
const instantiatedParameters = InstantiateElements({},
|
|
12
|
+
const instantiatedParameters = InstantiateElements({}, State([], []), parameters);
|
|
12
13
|
const result = Tuple(instantiatedParameters);
|
|
13
14
|
return result;
|
|
14
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TProperties } from '../../types/properties.mjs';
|
|
2
|
-
import { type
|
|
3
|
-
import { type TCyclicCheck } from '../cyclic/check.mjs';
|
|
2
|
+
import { type TInstantiateType } from '../instantiate.mjs';
|
|
4
3
|
import { type TRef } from '../../types/ref.mjs';
|
|
5
|
-
|
|
4
|
+
import { type TState } from '../instantiate.mjs';
|
|
5
|
+
export type TRefInstantiate<Context extends TProperties, State extends TState, Type extends TRef, Ref extends string> = (Ref extends State['visited'][number] ? Type : Ref extends keyof Context ? TInstantiateType<Context, TState<State['callstack'], [...State['visited'], Ref]>, Context[Ref]> : Type);
|
|
6
6
|
export declare function RefInstantiate<Context extends TProperties, State extends TState, Type extends TRef, Ref extends string>(context: Context, state: State, type: Type, ref: Ref): TRefInstantiate<Context, State, Type, Ref>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { InstantiateType } from '../instantiate.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { State } from '../instantiate.mjs';
|
|
4
4
|
export function RefInstantiate(context, state, type, ref) {
|
|
5
|
-
return (ref
|
|
6
|
-
?
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
return (state.visited.includes(ref)
|
|
6
|
+
? type
|
|
7
|
+
: ref in context
|
|
8
|
+
? InstantiateType(context, State(state['callstack'], [...state['visited'], ref]), context[ref])
|
|
9
|
+
: type);
|
|
10
10
|
}
|
|
@@ -6,6 +6,7 @@ import { type TExtendsLeft } from './extends_left.mjs';
|
|
|
6
6
|
import { type TExtendsRight } from './extends_right.mjs';
|
|
7
7
|
import * as Result from './result.mjs';
|
|
8
8
|
import { type TInstantiateElements } from '../engine/instantiate.mjs';
|
|
9
|
+
import { type TState } from '../engine/instantiate.mjs';
|
|
9
10
|
import { type TTryRestInferable, type TTryInferable, type TInferable, type TInferTupleResult, type TInferUnionResult } from './inference.mjs';
|
|
10
11
|
type TReverse<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReverse<Right, [Left, ...Result]> : Result);
|
|
11
12
|
type TApplyReverse<Types extends TSchema[], Reversed extends boolean> = Reversed extends true ? TReverse<Types> : Types;
|
|
@@ -14,12 +15,8 @@ type TElementsCompare<Inferred extends TProperties, Reversed extends boolean, Le
|
|
|
14
15
|
type TElementsLeft<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], Right extends TSchema, RightRest extends TSchema[], Inferable extends TInferable | undefined = TTryRestInferable<Right>> = (Inferable extends TInferable ? TInferTupleResult<Inferred, Inferable['name'], TApplyReverse<LeftRest, Reversed>, Inferable['type']> : LeftRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TElementsCompare<Inferred, Reversed, Head, Tail, Right, RightRest> : Result.TExtendsFalse);
|
|
15
16
|
type TElementsRight<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], RightRest extends TSchema[]> = (RightRest extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TElementsLeft<Inferred, Reversed, LeftRest, Head, Tail> : LeftRest['length'] extends 0 ? Result.TExtendsTrue<Inferred> : Result.TExtendsFalse);
|
|
16
17
|
type TElements<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], RightRest extends TSchema[]> = TElementsRight<Inferred, Reversed, LeftRest, RightRest>;
|
|
17
|
-
type TExtendsTupleToTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[], InstantiatedRight extends TSchema[] = TInstantiateElements<Inferred,
|
|
18
|
-
callstack: [];
|
|
19
|
-
}, Right>, Reversed extends boolean = TReversed<InstantiatedRight>> = TElements<Inferred, Reversed, TApplyReverse<Left, Reversed>, TApplyReverse<InstantiatedRight, Reversed>>;
|
|
18
|
+
type TExtendsTupleToTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[], InstantiatedRight extends TSchema[] = TInstantiateElements<Inferred, TState<[], []>, Right>, Reversed extends boolean = TReversed<InstantiatedRight>> = TElements<Inferred, Reversed, TApplyReverse<Left, Reversed>, TApplyReverse<InstantiatedRight, Reversed>>;
|
|
20
19
|
type TExtendsTupleToArray<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, Inferrable extends TInferable | undefined = TTryInferable<Right>> = (Inferrable extends TInferable ? TInferUnionResult<Inferred, Inferrable['name'], Left, Inferrable['type']> : Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Head, Right> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsTupleToArray<Inferred, Tail, Right> : Result.TExtendsFalse : Result.TExtendsTrue<Inferred>);
|
|
21
|
-
export type TExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, InstantiatedLeft extends TSchema[] = TInstantiateElements<Inferred,
|
|
22
|
-
callstack: [];
|
|
23
|
-
}, Left>> = (Right extends TTuple<infer Types extends TSchema[]> ? TExtendsTupleToTuple<Inferred, InstantiatedLeft, Types> : Right extends TArray<infer Type extends TSchema> ? TExtendsTupleToArray<Inferred, InstantiatedLeft, Type> : TExtendsRight<Inferred, TTuple<InstantiatedLeft>, Right>);
|
|
20
|
+
export type TExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, InstantiatedLeft extends TSchema[] = TInstantiateElements<Inferred, TState<[], []>, Left>> = (Right extends TTuple<infer Types extends TSchema[]> ? TExtendsTupleToTuple<Inferred, InstantiatedLeft, Types> : Right extends TArray<infer Type extends TSchema> ? TExtendsTupleToArray<Inferred, InstantiatedLeft, Type> : TExtendsRight<Inferred, TTuple<InstantiatedLeft>, Right>);
|
|
24
21
|
export declare function ExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsTuple<Inferred, Left, Right>;
|
|
25
22
|
export {};
|
|
@@ -7,6 +7,7 @@ import { ExtendsLeft } from './extends_left.mjs';
|
|
|
7
7
|
import { ExtendsRight } from './extends_right.mjs';
|
|
8
8
|
import * as Result from './result.mjs';
|
|
9
9
|
import { InstantiateElements } from '../engine/instantiate.mjs';
|
|
10
|
+
import { State } from '../engine/instantiate.mjs';
|
|
10
11
|
// ----------------------------------------------------------------------------
|
|
11
12
|
// Inference
|
|
12
13
|
// ----------------------------------------------------------------------------
|
|
@@ -42,7 +43,7 @@ function Elements(inferred, reversed, leftRest, rightRest) {
|
|
|
42
43
|
return ElementsRight(inferred, reversed, leftRest, rightRest);
|
|
43
44
|
}
|
|
44
45
|
function ExtendsTupleToTuple(inferred, left, right) {
|
|
45
|
-
const instantiatedRight = InstantiateElements(inferred,
|
|
46
|
+
const instantiatedRight = InstantiateElements(inferred, State([], []), right);
|
|
46
47
|
const reversed = Reversed(instantiatedRight);
|
|
47
48
|
return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
|
|
48
49
|
}
|
|
@@ -53,7 +54,7 @@ function ExtendsTupleToArray(inferred, left, right) {
|
|
|
53
54
|
: Guard.TakeLeft(left, (head, tail) => Result.Match(ExtendsLeft(inferred, head, right), inferred => ExtendsTupleToArray(inferred, tail, right), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred)));
|
|
54
55
|
}
|
|
55
56
|
export function ExtendsTuple(inferred, left, right) {
|
|
56
|
-
const instantiatedLeft = InstantiateElements(inferred,
|
|
57
|
+
const instantiatedLeft = InstantiateElements(inferred, State([], []), left);
|
|
57
58
|
return (IsTuple(right) ? ExtendsTupleToTuple(inferred, instantiatedLeft, right.items) :
|
|
58
59
|
IsArray(right) ? ExtendsTupleToArray(inferred, instantiatedLeft, right.items) :
|
|
59
60
|
ExtendsRight(inferred, Tuple(instantiatedLeft), right));
|
|
@@ -129,8 +129,14 @@ export type TKeywordVoidMapping<Input extends 'void'> = (T.TVoid);
|
|
|
129
129
|
export declare function KeywordVoidMapping(input: 'void'): unknown;
|
|
130
130
|
export type TKeywordThisMapping<Input extends 'this'> = (T.TThis);
|
|
131
131
|
export declare function KeywordThisMapping(input: 'this'): unknown;
|
|
132
|
-
export type
|
|
133
|
-
export declare function
|
|
132
|
+
export type TLiteralBigIntMapping<Input extends string> = (Input extends `${infer Value extends bigint}` ? T.TLiteral<Value> : never);
|
|
133
|
+
export declare function LiteralBigIntMapping(input: string): unknown;
|
|
134
|
+
export type TLiteralBooleanMapping<Input extends 'true' | 'false'> = (Input extends 'true' ? T.TLiteral<true> : T.TLiteral<false>);
|
|
135
|
+
export declare function LiteralBooleanMapping(input: 'true' | 'false'): unknown;
|
|
136
|
+
export type TLiteralNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? T.TLiteral<Value> : never);
|
|
137
|
+
export declare function LiteralNumberMapping(input: string): unknown;
|
|
138
|
+
export type TLiteralStringMapping<Input extends string> = (Input extends T.TLiteralValue ? T.TLiteral<Input> : never);
|
|
139
|
+
export declare function LiteralStringMapping(input: string): unknown;
|
|
134
140
|
export type TTemplateInterpolateMapping<Input extends [unknown, unknown, unknown]> = Input extends ['${', infer Type extends T.TSchema, '}'] ? Type : never;
|
|
135
141
|
export declare function TemplateInterpolateMapping(input: [unknown, unknown, unknown]): unknown;
|
|
136
142
|
export type TTemplateSpanMapping<Input extends string, Result extends T.TSchema = T.TLiteral<Input>> = Result;
|
|
@@ -142,16 +148,8 @@ export type TTemplateLiteralTypesMapping<Input extends [unknown, unknown, unknow
|
|
|
142
148
|
export declare function TemplateLiteralTypesMapping(input: [unknown, unknown, unknown]): unknown;
|
|
143
149
|
export type TTemplateLiteralMapping<Input extends unknown> = (Input extends infer Types extends T.TSchema[] ? T.TTemplateLiteralDeferred<Types> : never);
|
|
144
150
|
export declare function TemplateLiteralMapping(input: unknown): unknown;
|
|
145
|
-
export type
|
|
146
|
-
export declare function
|
|
147
|
-
export type TLiteralBooleanMapping<Input extends 'true' | 'false'> = (Input extends 'true' ? T.TLiteral<true> : T.TLiteral<false>);
|
|
148
|
-
export declare function LiteralBooleanMapping(input: 'true' | 'false'): unknown;
|
|
149
|
-
export type TLiteralNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? T.TLiteral<Value> : never);
|
|
150
|
-
export declare function LiteralNumberMapping(input: string): unknown;
|
|
151
|
-
export type TLiteralStringMapping<Input extends string> = (Input extends T.TLiteralValue ? T.TLiteral<Input> : never);
|
|
152
|
-
export declare function LiteralStringMapping(input: string): unknown;
|
|
153
|
-
export type TLiteralMapping<Input extends unknown> = (Input);
|
|
154
|
-
export declare function LiteralMapping(input: unknown): unknown;
|
|
151
|
+
export type TDependentMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]> = (Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema, 'else', infer Else extends T.TSchema] ? T.TDependent<If, Then, Else> : Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema] ? T.TDependent<If, Then, T.TUnknown> : never);
|
|
152
|
+
export declare function DependentMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]): unknown;
|
|
155
153
|
export type TKeyOfMapping<Input extends [unknown] | []> = (Input extends [unknown] ? true : false);
|
|
156
154
|
export declare function KeyOfMapping(input: [unknown] | []): unknown;
|
|
157
155
|
type TIndexArrayMappingReduce<Input extends unknown[], Result extends unknown[] = []> = (Input extends [infer Left extends unknown, ...infer Right extends unknown[]] ? Left extends ['[', infer Type extends T.TSchema, ']'] ? TIndexArrayMappingReduce<Right, [...Result, [Type]]> : TIndexArrayMappingReduce<Right, [...Result, []]> : Result);
|
|
@@ -245,8 +243,8 @@ export type TElementMapping<Input extends [unknown, unknown] | [unknown]> = (Inp
|
|
|
245
243
|
export declare function ElementMapping(input: [unknown, unknown] | [unknown]): unknown;
|
|
246
244
|
export type TElementListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>);
|
|
247
245
|
export declare function ElementListMapping(input: [unknown, unknown]): unknown;
|
|
248
|
-
export type
|
|
249
|
-
export declare function
|
|
246
|
+
export type T_Tuple_Mapping<Input extends [unknown, unknown, unknown]> = (Input extends ['[', infer Types extends T.TSchema[], ']'] ? T.TTuple<Types> : never);
|
|
247
|
+
export declare function _Tuple_Mapping(input: [unknown, unknown, unknown]): unknown;
|
|
250
248
|
export type TParameterReadonlyOptionalMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends [string, '?', ':', 'readonly', infer Type extends T.TSchema] ? T.TReadonlyAdd<T.TOptionalAdd<Type>> : never);
|
|
251
249
|
export declare function ParameterReadonlyOptionalMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
252
250
|
export type TParameterReadonlyMapping<Input extends [unknown, unknown, unknown, unknown]> = (Input extends [string, ':', 'readonly', infer Type extends T.TSchema] ? T.TReadonlyAdd<Type> : never);
|
|
@@ -263,8 +261,8 @@ export type TParameterListMapping<Input extends [unknown, unknown]> = (TDelimite
|
|
|
263
261
|
export declare function ParameterListMapping(input: [unknown, unknown]): unknown;
|
|
264
262
|
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);
|
|
265
263
|
export declare function _Function_Mapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
266
|
-
export type
|
|
267
|
-
export declare function
|
|
264
|
+
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);
|
|
265
|
+
export declare function _Constructor_Mapping(input: [unknown, unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
268
266
|
type TModifierOperation = 'add' | 'remove' | 'none';
|
|
269
267
|
type TApplyReadonly<Readonly extends TModifierOperation, Type extends T.TSchema> = (Readonly extends 'remove' ? C.TReadonlyRemoveAction<Type> : Readonly extends 'add' ? C.TReadonlyAddAction<Type> : Type);
|
|
270
268
|
export type TMappedReadonlyMapping<Input extends [unknown, unknown] | [unknown] | []> = (Input extends ['-', 'readonly'] ? 'remove' : Input extends ['+', 'readonly'] ? 'add' : Input extends ['readonly'] ? 'add' : 'none');
|
|
@@ -274,10 +272,8 @@ export type TMappedOptionalMapping<Input extends [unknown, unknown] | [unknown]
|
|
|
274
272
|
export declare function MappedOptionalMapping(input: [unknown, unknown] | [unknown] | []): unknown;
|
|
275
273
|
export type TMappedAsMapping<Input extends [unknown, unknown] | []> = (Input extends ['as', infer Type extends T.TSchema] ? [Type] : []);
|
|
276
274
|
export declare function MappedAsMapping(input: [unknown, unknown] | []): unknown;
|
|
277
|
-
export type
|
|
278
|
-
export declare function
|
|
279
|
-
export type TDependentMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]> = (Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema, 'else', infer Else extends T.TSchema] ? T.TDependent<If, Then, Else> : Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema] ? T.TDependent<If, Then, T.TUnknown> : never);
|
|
280
|
-
export declare function DependentMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]): unknown;
|
|
275
|
+
export type T_Mapped_Mapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]> = (Input extends ['{', infer Readonly extends TModifierOperation, '[', infer Key extends string, 'in', infer Type extends T.TSchema, infer As extends T.TSchema[], ']', infer Optional extends TModifierOperation, ':', infer Property extends T.TSchema, null, '}'] ? (As extends [infer As extends T.TSchema] ? C.TMappedDeferred<T.TIdentifier<Key>, Type, As, TApplyReadonly<Readonly, TApplyOptional<Optional, Property>>> : C.TMappedDeferred<T.TIdentifier<Key>, Type, T.TRef<Key>, TApplyReadonly<Readonly, TApplyOptional<Optional, Property>>>) : never);
|
|
276
|
+
export declare function _Mapped_Mapping(input: [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
281
277
|
export type TReferenceMapping<Input extends string, Result extends T.TSchema = T.TRef<Input>> = Result;
|
|
282
278
|
export declare function ReferenceMapping(input: string): unknown;
|
|
283
279
|
export type TJsonNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? Value : never);
|
|
@@ -129,8 +129,17 @@ export function KeywordVoidMapping(input) {
|
|
|
129
129
|
export function KeywordThisMapping(input) {
|
|
130
130
|
return T.This();
|
|
131
131
|
}
|
|
132
|
-
export function
|
|
133
|
-
return input;
|
|
132
|
+
export function LiteralBigIntMapping(input) {
|
|
133
|
+
return T.Literal(BigInt(input));
|
|
134
|
+
}
|
|
135
|
+
export function LiteralBooleanMapping(input) {
|
|
136
|
+
return T.Literal(Guard.IsEqual(input, 'true'));
|
|
137
|
+
}
|
|
138
|
+
export function LiteralNumberMapping(input) {
|
|
139
|
+
return T.Literal(parseFloat(input));
|
|
140
|
+
}
|
|
141
|
+
export function LiteralStringMapping(input) {
|
|
142
|
+
return T.Literal(input);
|
|
134
143
|
}
|
|
135
144
|
export function TemplateInterpolateMapping(input) {
|
|
136
145
|
return input[1];
|
|
@@ -149,20 +158,9 @@ export function TemplateLiteralTypesMapping(input) {
|
|
|
149
158
|
export function TemplateLiteralMapping(input) {
|
|
150
159
|
return T.TemplateLiteralDeferred(input);
|
|
151
160
|
}
|
|
152
|
-
export function
|
|
153
|
-
return T.
|
|
154
|
-
|
|
155
|
-
export function LiteralBooleanMapping(input) {
|
|
156
|
-
return T.Literal(Guard.IsEqual(input, 'true'));
|
|
157
|
-
}
|
|
158
|
-
export function LiteralNumberMapping(input) {
|
|
159
|
-
return T.Literal(parseFloat(input));
|
|
160
|
-
}
|
|
161
|
-
export function LiteralStringMapping(input) {
|
|
162
|
-
return T.Literal(input);
|
|
163
|
-
}
|
|
164
|
-
export function LiteralMapping(input) {
|
|
165
|
-
return input;
|
|
161
|
+
export function DependentMapping(input) {
|
|
162
|
+
return (Guard.IsEqual(input.length, 6) ? T.Dependent(input[1], input[3], input[5]) :
|
|
163
|
+
T.Dependent(input[1], input[3], T.Unknown()));
|
|
166
164
|
}
|
|
167
165
|
export function KeyOfMapping(input) {
|
|
168
166
|
return input.length > 0;
|
|
@@ -349,7 +347,7 @@ export function ElementMapping(input) {
|
|
|
349
347
|
export function ElementListMapping(input) {
|
|
350
348
|
return Delimited(input);
|
|
351
349
|
}
|
|
352
|
-
export function
|
|
350
|
+
export function _Tuple_Mapping(input) {
|
|
353
351
|
return T.Tuple(input[1]);
|
|
354
352
|
}
|
|
355
353
|
export function ParameterReadonlyOptionalMapping(input) {
|
|
@@ -379,7 +377,7 @@ export function ParameterListMapping(input) {
|
|
|
379
377
|
export function _Function_Mapping(input) {
|
|
380
378
|
return T._Function_(input[1], input[4]);
|
|
381
379
|
}
|
|
382
|
-
export function
|
|
380
|
+
export function _Constructor_Mapping(input) {
|
|
383
381
|
return T.Constructor(input[2], input[5]);
|
|
384
382
|
}
|
|
385
383
|
function ApplyReadonly(state, type) {
|
|
@@ -407,15 +405,11 @@ export function MappedOptionalMapping(input) {
|
|
|
407
405
|
export function MappedAsMapping(input) {
|
|
408
406
|
return Guard.IsEqual(input.length, 2) ? [input[1]] : [];
|
|
409
407
|
}
|
|
410
|
-
export function
|
|
408
|
+
export function _Mapped_Mapping(input) {
|
|
411
409
|
return (Guard.IsArray(input[6]) && Guard.IsEqual(input[6].length, 1)
|
|
412
410
|
? C.MappedDeferred(T.Identifier(input[3]), input[5], input[6][0], ApplyReadonly(input[1], ApplyOptional(input[8], input[10])))
|
|
413
411
|
: C.MappedDeferred(T.Identifier(input[3]), input[5], T.Ref(input[3]), ApplyReadonly(input[1], ApplyOptional(input[8], input[10]))));
|
|
414
412
|
}
|
|
415
|
-
export function DependentMapping(input) {
|
|
416
|
-
return (Guard.IsEqual(input.length, 6) ? T.Dependent(input[1], input[3], input[5]) :
|
|
417
|
-
T.Dependent(input[1], input[3], T.Unknown()));
|
|
418
|
-
}
|
|
419
413
|
export function ReferenceMapping(input) {
|
|
420
414
|
return T.Ref(input);
|
|
421
415
|
}
|
|
@@ -27,22 +27,21 @@ export type TKeywordNever<Input extends string> = Token.TConst<'never', Input> e
|
|
|
27
27
|
export type TKeywordSymbol<Input extends string> = Token.TConst<'symbol', Input> extends [infer _0 extends 'symbol', infer Input extends string] ? [S.TKeywordSymbolMapping<_0>, Input] : [];
|
|
28
28
|
export type TKeywordVoid<Input extends string> = Token.TConst<'void', Input> extends [infer _0 extends 'void', infer Input extends string] ? [S.TKeywordVoidMapping<_0>, Input] : [];
|
|
29
29
|
export type TKeywordThis<Input extends string> = Token.TConst<'this', Input> extends [infer _0 extends 'this', infer Input extends string] ? [S.TKeywordThisMapping<_0>, Input] : [];
|
|
30
|
-
export type TKeyword<Input extends string> = (TKeywordString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordUndefined<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNull<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordInteger<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordUnknown<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordAny<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordObject<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNever<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordSymbol<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordVoid<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordThis<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TKeywordMapping<_0>, Input] : [];
|
|
31
30
|
export type TTemplateInterpolate<Input extends string> = (Token.TConst<'${', Input> extends [infer _0, infer Input extends string] ? (TType<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.TTemplateInterpolateMapping<_0>, Input] : [];
|
|
32
31
|
export type TTemplateSpan<Input extends string> = Token.TUntil<['${', '`'], Input> extends [infer _0 extends string, infer Input extends string] ? [S.TTemplateSpanMapping<_0>, Input] : [];
|
|
33
32
|
export type TTemplateBody<Input extends string> = ((TTemplateSpan<Input> extends [infer _0, infer Input extends string] ? (TTemplateInterpolate<Input> extends [infer _1, infer Input extends string] ? (TTemplateBody<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TTemplateSpan<Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (TTemplateSpan<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] | [unknown], infer Input extends string] ? [S.TTemplateBodyMapping<_0>, Input] : [];
|
|
34
33
|
export type TTemplateLiteralTypes<Input extends string> = (Token.TConst<'`', Input> extends [infer _0, infer Input extends string] ? (TTemplateBody<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.TTemplateLiteralTypesMapping<_0>, Input] : [];
|
|
35
34
|
export type TTemplateLiteral<Input extends string> = TTemplateLiteralTypes<Input> extends [infer _0 extends unknown, infer Input extends string] ? [S.TTemplateLiteralMapping<_0>, Input] : [];
|
|
35
|
+
export type TDependent<Input extends string> = ((Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'else', 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, infer Input extends string] ? [_0, Input] : (Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', 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] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TDependentMapping<_0>, Input] : [];
|
|
36
36
|
export type TLiteralBigInt<Input extends string> = Token.TBigInt<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TLiteralBigIntMapping<_0>, Input] : [];
|
|
37
37
|
export type TLiteralBoolean<Input extends string> = (Token.TConst<'true', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : Token.TConst<'false', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends 'true' | 'false', infer Input extends string] ? [S.TLiteralBooleanMapping<_0>, Input] : [];
|
|
38
38
|
export type TLiteralNumber<Input extends string> = Token.TNumber<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TLiteralNumberMapping<_0>, Input] : [];
|
|
39
39
|
export type TLiteralString<Input extends string> = Token.TString<['\'', '\"'], Input> extends [infer _0 extends string, infer Input extends string] ? [S.TLiteralStringMapping<_0>, Input] : [];
|
|
40
|
-
export type TLiteral<Input extends string> = (TLiteralBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends unknown, infer Input extends string] ? [S.TLiteralMapping<_0>, Input] : [];
|
|
41
40
|
export type TKeyOf<Input extends string> = ((Token.TConst<'keyof', 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.TKeyOfMapping<_0>, Input] : [];
|
|
42
41
|
export type TIndexArray_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] ? (Token.TConst<']', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0, infer Input extends string] ? TIndexArray_0<Input, [...Result, _0]> : [Result, Input];
|
|
43
42
|
export type TIndexArray<Input extends string> = TIndexArray_0<Input> extends [infer _0 extends ([unknown, unknown, unknown] | [unknown, unknown])[], infer Input extends string] ? [S.TIndexArrayMapping<_0>, Input] : [];
|
|
44
43
|
export type TExtends<Input extends string> = ((Token.TConst<'extends', Input> extends [infer _0, infer Input extends string] ? (TType<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] ? (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, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExtendsMapping<_0>, Input] : [];
|
|
45
|
-
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<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, infer Input extends string] ? [_0, Input] :
|
|
44
|
+
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<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, infer Input extends string] ? [_0, Input] : TKeywordString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordUndefined<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNull<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordInteger<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordUnknown<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordAny<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordObject<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordNever<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordSymbol<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordVoid<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TKeywordThis<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralBigInt<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralBoolean<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralNumber<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteralString<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTemplateLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TDependent<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Object_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Tuple_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Constructor_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Function_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Mapped_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericCall<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TReference<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | unknown, infer Input extends string] ? [S.TBaseMapping<_0>, Input] : [];
|
|
46
45
|
export type TWith<Input extends string> = ((Token.TConst<'with', Input> extends [infer _0, infer Input extends string] ? (TJsonObject<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.TWithMapping<_0>, Input] : [];
|
|
47
46
|
export type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends<Input> extends [infer _3, infer Input extends string] ? (TWith<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.TFactorMapping<_0>, Input] : [];
|
|
48
47
|
export type TExprTermTail<Input extends string> = ((Token.TConst<'&', Input> extends [infer _0, infer Input extends string] ? (TFactor<Input> extends [infer _1, infer Input extends string] ? (TExprTermTail<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.TExprTermTailMapping<_0>, Input] : [];
|
|
@@ -75,7 +74,7 @@ export type TElementBase<Input extends string> = (TElementNamed<Input> extends [
|
|
|
75
74
|
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] : [];
|
|
76
75
|
export type TElementList_0<Input extends string, Result extends unknown[] = []> = (TElement<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<',', 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];
|
|
77
76
|
export type TElementList<Input extends string> = (TElementList_0<Input> extends [infer _0, infer Input extends string] ? (((TElement<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 _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TElementListMapping<_0>, Input] : [];
|
|
78
|
-
export type
|
|
77
|
+
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] : [];
|
|
79
78
|
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] : [];
|
|
80
79
|
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
80
|
export type TParameterOptional<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] ? (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.TParameterOptionalMapping<_0>, Input] : [];
|
|
@@ -85,12 +84,11 @@ export type TParameter<Input extends string> = ((Token.TConst<'...', Input> exte
|
|
|
85
84
|
export type TParameterList_0<Input extends string, Result extends unknown[] = []> = (TParameter<Input> extends [infer _0, infer Input extends string] ? (Token.TConst<',', 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];
|
|
86
85
|
export type TParameterList<Input extends string> = (TParameterList_0<Input> extends [infer _0, infer Input extends string] ? (((TParameter<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 _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TParameterListMapping<_0>, Input] : [];
|
|
87
86
|
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] : [];
|
|
88
|
-
export type
|
|
87
|
+
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] : [];
|
|
89
88
|
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] : [];
|
|
90
89
|
export type TMappedOptional<Input extends string> = ((Token.TConst<'+', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', 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<'?', 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] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown] | [], infer Input extends string] ? [S.TMappedOptionalMapping<_0>, Input] : [];
|
|
91
90
|
export type TMappedAs<Input extends string> = ((Token.TConst<'as', 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] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [], infer Input extends string] ? [S.TMappedAsMapping<_0>, Input] : [];
|
|
92
|
-
export type
|
|
93
|
-
export type TDependent<Input extends string> = ((Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'else', 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, infer Input extends string] ? [_0, Input] : (Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', 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] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TDependentMapping<_0>, Input] : [];
|
|
91
|
+
export type T_Mapped_<Input extends string> = (Token.TConst<'{', Input> extends [infer _0, infer Input extends string] ? (TMappedReadonly<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'[', Input> extends [infer _2, infer Input extends string] ? (Token.TIdent<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'in', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? (TMappedAs<Input> extends [infer _6, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _7, infer Input extends string] ? (TMappedOptional<Input> extends [infer _8, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _9, infer Input extends string] ? (TType<Input> extends [infer _10, infer Input extends string] ? (TOptionalSemiColon<Input> extends [infer _11, infer Input extends string] ? (Token.TConst<'}', Input> extends [infer _12, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], Input] : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.T_Mapped_Mapping<_0>, Input] : [];
|
|
94
92
|
export type TReference<Input extends string> = Token.TIdent<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TReferenceMapping<_0>, Input] : [];
|
|
95
93
|
export type TJsonNumber<Input extends string> = Token.TNumber<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TJsonNumberMapping<_0>, Input] : [];
|
|
96
94
|
export type TJsonBoolean<Input extends string> = (Token.TConst<'true', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : Token.TConst<'false', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends 'true' | 'false', infer Input extends string] ? [S.TJsonBooleanMapping<_0>, Input] : [];
|
|
@@ -157,17 +155,16 @@ export declare const KeywordNever: (input: string) => [unknown, string] | [];
|
|
|
157
155
|
export declare const KeywordSymbol: (input: string) => [unknown, string] | [];
|
|
158
156
|
export declare const KeywordVoid: (input: string) => [unknown, string] | [];
|
|
159
157
|
export declare const KeywordThis: (input: string) => [unknown, string] | [];
|
|
160
|
-
export declare const Keyword: (input: string) => [unknown, string] | [];
|
|
161
158
|
export declare const TemplateInterpolate: (input: string) => [unknown, string] | [];
|
|
162
159
|
export declare const TemplateSpan: (input: string) => [unknown, string] | [];
|
|
163
160
|
export declare const TemplateBody: (input: string) => [unknown, string] | [];
|
|
164
161
|
export declare const TemplateLiteralTypes: (input: string) => [unknown, string] | [];
|
|
165
162
|
export declare const TemplateLiteral: (input: string) => [unknown, string] | [];
|
|
163
|
+
export declare const Dependent: (input: string) => [unknown, string] | [];
|
|
166
164
|
export declare const LiteralBigInt: (input: string) => [unknown, string] | [];
|
|
167
165
|
export declare const LiteralBoolean: (input: string) => [unknown, string] | [];
|
|
168
166
|
export declare const LiteralNumber: (input: string) => [unknown, string] | [];
|
|
169
167
|
export declare const LiteralString: (input: string) => [unknown, string] | [];
|
|
170
|
-
export declare const Literal: (input: string) => [unknown, string] | [];
|
|
171
168
|
export declare const KeyOf: (input: string) => [unknown, string] | [];
|
|
172
169
|
export declare const IndexArray_0: (input: string, result?: unknown[]) => [unknown[], string];
|
|
173
170
|
export declare const IndexArray: (input: string) => [unknown, string] | [];
|
|
@@ -205,7 +202,7 @@ export declare const ElementBase: (input: string) => [unknown, string] | [];
|
|
|
205
202
|
export declare const Element: (input: string) => [unknown, string] | [];
|
|
206
203
|
export declare const ElementList_0: (input: string, result?: unknown[]) => [unknown[], string];
|
|
207
204
|
export declare const ElementList: (input: string) => [unknown, string] | [];
|
|
208
|
-
export declare const
|
|
205
|
+
export declare const _Tuple_: (input: string) => [unknown, string] | [];
|
|
209
206
|
export declare const ParameterReadonlyOptional: (input: string) => [unknown, string] | [];
|
|
210
207
|
export declare const ParameterReadonly: (input: string) => [unknown, string] | [];
|
|
211
208
|
export declare const ParameterOptional: (input: string) => [unknown, string] | [];
|
|
@@ -215,12 +212,11 @@ export declare const Parameter: (input: string) => [unknown, string] | [];
|
|
|
215
212
|
export declare const ParameterList_0: (input: string, result?: unknown[]) => [unknown[], string];
|
|
216
213
|
export declare const ParameterList: (input: string) => [unknown, string] | [];
|
|
217
214
|
export declare const _Function_: (input: string) => [unknown, string] | [];
|
|
218
|
-
export declare const
|
|
215
|
+
export declare const _Constructor_: (input: string) => [unknown, string] | [];
|
|
219
216
|
export declare const MappedReadonly: (input: string) => [unknown, string] | [];
|
|
220
217
|
export declare const MappedOptional: (input: string) => [unknown, string] | [];
|
|
221
218
|
export declare const MappedAs: (input: string) => [unknown, string] | [];
|
|
222
|
-
export declare const
|
|
223
|
-
export declare const Dependent: (input: string) => [unknown, string] | [];
|
|
219
|
+
export declare const _Mapped_: (input: string) => [unknown, string] | [];
|
|
224
220
|
export declare const Reference: (input: string) => [unknown, string] | [];
|
|
225
221
|
export declare const JsonNumber: (input: string) => [unknown, string] | [];
|
|
226
222
|
export declare const JsonBoolean: (input: string) => [unknown, string] | [];
|
|
@@ -31,22 +31,21 @@ export const KeywordNever = (input) => If(Token.Const('never', input), ([_0, inp
|
|
|
31
31
|
export const KeywordSymbol = (input) => If(Token.Const('symbol', input), ([_0, input]) => [S.KeywordSymbolMapping(_0), input]);
|
|
32
32
|
export const KeywordVoid = (input) => If(Token.Const('void', input), ([_0, input]) => [S.KeywordVoidMapping(_0), input]);
|
|
33
33
|
export const KeywordThis = (input) => If(Token.Const('this', input), ([_0, input]) => [S.KeywordThisMapping(_0), input]);
|
|
34
|
-
export const Keyword = (input) => If(If(KeywordString(input), ([_0, input]) => [_0, input], () => If(KeywordNumber(input), ([_0, input]) => [_0, input], () => If(KeywordBoolean(input), ([_0, input]) => [_0, input], () => If(KeywordUndefined(input), ([_0, input]) => [_0, input], () => If(KeywordNull(input), ([_0, input]) => [_0, input], () => If(KeywordInteger(input), ([_0, input]) => [_0, input], () => If(KeywordBigInt(input), ([_0, input]) => [_0, input], () => If(KeywordUnknown(input), ([_0, input]) => [_0, input], () => If(KeywordAny(input), ([_0, input]) => [_0, input], () => If(KeywordObject(input), ([_0, input]) => [_0, input], () => If(KeywordNever(input), ([_0, input]) => [_0, input], () => If(KeywordSymbol(input), ([_0, input]) => [_0, input], () => If(KeywordVoid(input), ([_0, input]) => [_0, input], () => If(KeywordThis(input), ([_0, input]) => [_0, input], () => [])))))))))))))), ([_0, input]) => [S.KeywordMapping(_0), input]);
|
|
35
34
|
export const TemplateInterpolate = (input) => If(If(Token.Const('${', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.TemplateInterpolateMapping(_0), input]);
|
|
36
35
|
export const TemplateSpan = (input) => If(Token.Until(['${', '`'], input), ([_0, input]) => [S.TemplateSpanMapping(_0), input]);
|
|
37
36
|
export const TemplateBody = (input) => If(If(If(TemplateSpan(input), ([_0, input]) => If(TemplateInterpolate(input), ([_1, input]) => If(TemplateBody(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(If(TemplateSpan(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If(If(TemplateSpan(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => []))), ([_0, input]) => [S.TemplateBodyMapping(_0), input]);
|
|
38
37
|
export const TemplateLiteralTypes = (input) => If(If(Token.Const('`', input), ([_0, input]) => If(TemplateBody(input), ([_1, input]) => If(Token.Const('`', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.TemplateLiteralTypesMapping(_0), input]);
|
|
39
38
|
export const TemplateLiteral = (input) => If(TemplateLiteralTypes(input), ([_0, input]) => [S.TemplateLiteralMapping(_0), input]);
|
|
39
|
+
export const Dependent = (input) => If(If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const('else', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.DependentMapping(_0), input]);
|
|
40
40
|
export const LiteralBigInt = (input) => If(Token.BigInt(input), ([_0, input]) => [S.LiteralBigIntMapping(_0), input]);
|
|
41
41
|
export const LiteralBoolean = (input) => If(If(Token.Const('true', input), ([_0, input]) => [_0, input], () => If(Token.Const('false', input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.LiteralBooleanMapping(_0), input]);
|
|
42
42
|
export const LiteralNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.LiteralNumberMapping(_0), input]);
|
|
43
43
|
export const LiteralString = (input) => If(Token.String(['\'', '\"'], input), ([_0, input]) => [S.LiteralStringMapping(_0), input]);
|
|
44
|
-
export const Literal = (input) => If(If(LiteralBigInt(input), ([_0, input]) => [_0, input], () => If(LiteralBoolean(input), ([_0, input]) => [_0, input], () => If(LiteralNumber(input), ([_0, input]) => [_0, input], () => If(LiteralString(input), ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.LiteralMapping(_0), input]);
|
|
45
44
|
export const KeyOf = (input) => If(If(If(Token.Const('keyof', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.KeyOfMapping(_0), input]);
|
|
46
45
|
export const IndexArray_0 = (input, result = []) => If(If(If(Token.Const('[', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(If(Token.Const('[', input), ([_0, input]) => If(Token.Const(']', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => IndexArray_0(input, [...result, _0]), () => [result, input]);
|
|
47
46
|
export const IndexArray = (input) => If(IndexArray_0(input), ([_0, input]) => [S.IndexArrayMapping(_0), input]);
|
|
48
47
|
export const Extends = (input) => If(If(If(Token.Const('extends', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('?', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const(':', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExtendsMapping(_0), input]);
|
|
49
|
-
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(
|
|
48
|
+
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(KeywordString(input), ([_0, input]) => [_0, input], () => If(KeywordNumber(input), ([_0, input]) => [_0, input], () => If(KeywordBoolean(input), ([_0, input]) => [_0, input], () => If(KeywordUndefined(input), ([_0, input]) => [_0, input], () => If(KeywordNull(input), ([_0, input]) => [_0, input], () => If(KeywordInteger(input), ([_0, input]) => [_0, input], () => If(KeywordBigInt(input), ([_0, input]) => [_0, input], () => If(KeywordUnknown(input), ([_0, input]) => [_0, input], () => If(KeywordAny(input), ([_0, input]) => [_0, input], () => If(KeywordObject(input), ([_0, input]) => [_0, input], () => If(KeywordNever(input), ([_0, input]) => [_0, input], () => If(KeywordSymbol(input), ([_0, input]) => [_0, input], () => If(KeywordVoid(input), ([_0, input]) => [_0, input], () => If(KeywordThis(input), ([_0, input]) => [_0, input], () => If(LiteralBigInt(input), ([_0, input]) => [_0, input], () => If(LiteralBoolean(input), ([_0, input]) => [_0, input], () => If(LiteralNumber(input), ([_0, input]) => [_0, input], () => If(LiteralString(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Dependent(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(_Tuple_(input), ([_0, input]) => [_0, input], () => If(_Constructor_(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(_Mapped_(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))))))))))))))))))), ([_0, input]) => [S.BaseMapping(_0), input]);
|
|
50
49
|
export const With = (input) => If(If(If(Token.Const('with', input), ([_0, input]) => If(JsonObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithMapping(_0), input]);
|
|
51
50
|
export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => If(With(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.FactorMapping(_0), input]);
|
|
52
51
|
export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, input]) => If(Factor(input), ([_1, input]) => If(ExprTermTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTermTailMapping(_0), input]);
|
|
@@ -79,7 +78,7 @@ export const ElementBase = (input) => If(If(ElementNamed(input), ([_0, input]) =
|
|
|
79
78
|
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]);
|
|
80
79
|
export const ElementList_0 = (input, result = []) => If(If(Element(input), ([_0, input]) => If(Token.Const(',', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => ElementList_0(input, [...result, _0]), () => [result, input]);
|
|
81
80
|
export const ElementList = (input) => If(If(ElementList_0(input), ([_0, input]) => If(If(If(Element(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ElementListMapping(_0), input]);
|
|
82
|
-
export const
|
|
81
|
+
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]);
|
|
83
82
|
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]);
|
|
84
83
|
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
84
|
export const ParameterOptional = (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]) => [S.ParameterOptionalMapping(_0), input]);
|
|
@@ -89,12 +88,11 @@ export const Parameter = (input) => If(If(If(Token.Const('...', input), ([_0, in
|
|
|
89
88
|
export const ParameterList_0 = (input, result = []) => If(If(Parameter(input), ([_0, input]) => If(Token.Const(',', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => ParameterList_0(input, [...result, _0]), () => [result, input]);
|
|
90
89
|
export const ParameterList = (input) => If(If(ParameterList_0(input), ([_0, input]) => If(If(If(Parameter(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ParameterListMapping(_0), input]);
|
|
91
90
|
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]);
|
|
92
|
-
export const
|
|
91
|
+
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]);
|
|
93
92
|
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]);
|
|
94
93
|
export const MappedOptional = (input) => If(If(If(Token.Const('+', input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('-', input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('?', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.MappedOptionalMapping(_0), input]);
|
|
95
94
|
export const MappedAs = (input) => If(If(If(Token.Const('as', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.MappedAsMapping(_0), input]);
|
|
96
|
-
export const
|
|
97
|
-
export const Dependent = (input) => If(If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const('else', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.DependentMapping(_0), input]);
|
|
95
|
+
export const _Mapped_ = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(MappedReadonly(input), ([_1, input]) => If(Token.Const('[', input), ([_2, input]) => If(Token.Ident(input), ([_3, input]) => If(Token.Const('in', input), ([_4, input]) => If(Type(input), ([_5, input]) => If(MappedAs(input), ([_6, input]) => If(Token.Const(']', input), ([_7, input]) => If(MappedOptional(input), ([_8, input]) => If(Token.Const(':', input), ([_9, input]) => If(Type(input), ([_10, input]) => If(OptionalSemiColon(input), ([_11, input]) => If(Token.Const('}', input), ([_12, input]) => [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], input]))))))))))))), ([_0, input]) => [S._Mapped_Mapping(_0), input]);
|
|
98
96
|
export const Reference = (input) => If(Token.Ident(input), ([_0, input]) => [S.ReferenceMapping(_0), input]);
|
|
99
97
|
export const JsonNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.JsonNumberMapping(_0), input]);
|
|
100
98
|
export const JsonBoolean = (input) => If(If(Token.Const('true', input), ([_0, input]) => [_0, input], () => If(Token.Const('false', input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.JsonBooleanMapping(_0), input]);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { TArrayOptions, TIntersectOptions, TNumberOptions, TObjectOptions, TStringOptions, TTupleOptions } from '../../type/index.mjs';
|
|
2
|
-
import { type TInstantiateType } from '../engine/instantiate.mjs';
|
|
3
2
|
import { type TNever, type TSchema, type TProperties } from '../types/index.mjs';
|
|
3
|
+
import { type TInstantiateType } from '../engine/instantiate.mjs';
|
|
4
|
+
import { type TState } from '../engine/instantiate.mjs';
|
|
4
5
|
import * as Parser from './parser.mjs';
|
|
5
6
|
export type TScriptOptions = TArrayOptions | TIntersectOptions | TNumberOptions | TObjectOptions | TStringOptions | TTupleOptions;
|
|
6
7
|
/** Parses a string-based TypeScript type expression into a TypeBox type. */
|
|
7
|
-
export type TScript<Context extends TProperties, Input extends string> = (Parser.TScript<Input> extends [infer Type extends TSchema, string] ? TInstantiateType<Context,
|
|
8
|
-
callstack: [];
|
|
9
|
-
}, Type> : TNever);
|
|
8
|
+
export type TScript<Context extends TProperties, Input extends string> = (Parser.TScript<Input> extends [infer Type extends TSchema, string] ? TInstantiateType<Context, TState<[], []>, Type> : TNever);
|
|
10
9
|
/** Parses a type from a TypeScript type expression */
|
|
11
10
|
export declare function Script<Script extends string>(input: Script): TScript<{}, Script>;
|
|
12
11
|
/** Parses a type from a TypeScript type expression */
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { Arguments } from '../../system/arguments/index.mjs';
|
|
4
4
|
import { Memory } from '../../system/memory/index.mjs';
|
|
5
5
|
import { Guard } from '../../guard/index.mjs';
|
|
6
|
-
import { InstantiateType } from '../engine/instantiate.mjs';
|
|
7
6
|
import { Never } from '../types/index.mjs';
|
|
7
|
+
import { InstantiateType } from '../engine/instantiate.mjs';
|
|
8
|
+
import { State } from '../engine/instantiate.mjs';
|
|
8
9
|
import * as Parser from './parser.mjs';
|
|
9
10
|
/** Parses a type from a TypeScript type expression */
|
|
10
11
|
export function Script(...args) {
|
|
@@ -15,7 +16,7 @@ export function Script(...args) {
|
|
|
15
16
|
});
|
|
16
17
|
const result = Parser.Script(input);
|
|
17
18
|
const parsed = Guard.IsArray(result) && Guard.IsEqual(result.length, 2)
|
|
18
|
-
? InstantiateType(context,
|
|
19
|
+
? InstantiateType(context, State([], []), result[0])
|
|
19
20
|
: Never();
|
|
20
21
|
return Memory.Update(parsed, {}, options);
|
|
21
22
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type TSchema } from './schema.mjs';
|
|
2
2
|
import { type TCallInstantiate } from '../engine/call/instantiate.mjs';
|
|
3
|
+
import { type TState } from '../engine/instantiate.mjs';
|
|
3
4
|
/** Represents a deferred generic Call */
|
|
4
5
|
export interface TCall<Target extends TSchema = TSchema, Arguments extends TSchema[] = TSchema[]> extends TSchema {
|
|
5
6
|
'~kind': 'Call';
|
|
7
|
+
type: 'call';
|
|
6
8
|
target: Target;
|
|
7
9
|
arguments: Arguments;
|
|
8
10
|
}
|
|
9
11
|
export type TCallConstruct<Target extends TSchema, Arguments extends TSchema[], Result extends TSchema = TCall<Target, Arguments>> = Result;
|
|
10
12
|
export declare function CallConstruct<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallConstruct<Target, Arguments>;
|
|
11
13
|
/** Creates a Call type. */
|
|
12
|
-
export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{},
|
|
13
|
-
callstack: [];
|
|
14
|
-
}, Target, Arguments>;
|
|
14
|
+
export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{}, TState<[], []>, Target, Arguments>;
|
|
15
15
|
/** Returns true if the given type is a TCall. */
|
|
16
16
|
export declare function IsCall(value: unknown): value is TCall;
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
import { Memory } from '../../system/memory/index.mjs';
|
|
4
4
|
import { IsKind } from './schema.mjs';
|
|
5
5
|
import { CallInstantiate } from '../engine/call/instantiate.mjs';
|
|
6
|
+
import { State } from '../engine/instantiate.mjs';
|
|
6
7
|
export function CallConstruct(target, arguments_) {
|
|
7
|
-
return Memory.Create({ ['~kind']: 'Call' }, { target, arguments: arguments_ }, {});
|
|
8
|
+
return Memory.Create({ ['~kind']: 'Call' }, { type: 'call', target, arguments: arguments_ }, {});
|
|
8
9
|
}
|
|
9
10
|
// ------------------------------------------------------------------
|
|
10
11
|
// Factory
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
/** Creates a Call type. */
|
|
13
14
|
export function Call(target, arguments_) {
|
|
14
|
-
return CallInstantiate({},
|
|
15
|
+
return CallInstantiate({}, State([], []), target, arguments_);
|
|
15
16
|
}
|
|
16
17
|
// ------------------------------------------------------------------
|
|
17
18
|
// Guard
|