| import { type TSchema, type TSchemaOptions } from '../types/schema.mjs'; | ||
| import { type TDeferred } from '../types/deferred.mjs'; | ||
| import { type TConditionalAction } from '../engine/conditional/instantiate.mjs'; | ||
| import { type TState } from '../engine/instantiate.mjs'; | ||
| /** Creates a deferred Conditional action. */ | ||
@@ -9,6 +10,4 @@ export type TConditionalDeferred<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TDeferred<'Conditional', [Left, Right, True, False]>); | ||
| /** Applies a Conditional action to the given types. */ | ||
| export type TConditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TConditionalAction<{}, { | ||
| callstack: []; | ||
| }, Left, Right, True, False>); | ||
| export type TConditional<Left extends TSchema, Right extends TSchema, True extends TSchema, False extends TSchema> = (TConditionalAction<{}, TState<[], []>, Left, Right, True, False>); | ||
| /** Applies a Conditional action to the given types. */ | ||
| 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>; |
@@ -5,2 +5,3 @@ // deno-lint-ignore-file ban-types | ||
| import { ConditionalAction } from '../engine/conditional/instantiate.mjs'; | ||
| import { State } from '../engine/instantiate.mjs'; | ||
| /** Creates a deferred Conditional action. */ | ||
@@ -12,3 +13,3 @@ export function ConditionalDeferred(left, right, true_, false_, options = {}) { | ||
| export function Conditional(left, right, true_, false_, options = {}) { | ||
| return ConditionalAction({}, { callstack: [] }, left, right, true_, false_, options); | ||
| return ConditionalAction({}, State([], []), left, right, true_, false_, options); | ||
| } |
@@ -5,2 +5,3 @@ import { type TSchema, type TSchemaOptions } from '../types/schema.mjs'; | ||
| import { type TMappedAction } from '../engine/mapped/instantiate.mjs'; | ||
| import { type TState } from '../engine/instantiate.mjs'; | ||
| /** Creates a deferred Mapped action. */ | ||
@@ -11,6 +12,4 @@ export type TMappedDeferred<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TDeferred<'Mapped', [Identifier, Type, As, Property]>); | ||
| /** Applies a Mapped action using the given types. */ | ||
| export type TMapped<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TMappedAction<{}, { | ||
| callstack: []; | ||
| }, Identifier, Type, As, Property>); | ||
| export type TMapped<Identifier extends TIdentifier, Type extends TSchema, As extends TSchema, Property extends TSchema> = (TMappedAction<{}, TState<[], []>, Identifier, Type, As, Property>); | ||
| /** Applies a Mapped action using the given types. */ | ||
| 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>; |
@@ -5,2 +5,3 @@ // deno-lint-ignore-file ban-types | ||
| import { MappedAction } from '../engine/mapped/instantiate.mjs'; | ||
| import { State } from '../engine/instantiate.mjs'; | ||
| /** Creates a deferred Mapped action. */ | ||
@@ -12,3 +13,3 @@ export function MappedDeferred(identifier, type, as, property, options = {}) { | ||
| export function Mapped(identifier, type, as, property, options = {}) { | ||
| return MappedAction({}, { callstack: [] }, identifier, type, as, property, options); | ||
| return MappedAction({}, State([], []), identifier, type, as, property, options); | ||
| } |
@@ -16,5 +16,3 @@ import { type TSchema } from '../../types/schema.mjs'; | ||
| type TIsTailCall<State extends TState, Name extends string, Result extends boolean = TPeek<State> extends Name ? true : false> = Result; | ||
| 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, { | ||
| callstack: [...State['callstack'], Target['$ref']]; | ||
| }, Expression>> = TInstantiateType<Context, State, ReturnType>; | ||
| 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>; | ||
| 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); | ||
@@ -21,0 +19,0 @@ 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; |
@@ -9,2 +9,3 @@ // deno-fmt-ignore-file | ||
| import { InstantiateTypes } from '../instantiate.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| // ------------------------------------------------------------------ | ||
@@ -26,4 +27,4 @@ // Infrastructure | ||
| const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_); | ||
| const returnType = InstantiateType(argumentsContext, { callstack: [...state.callstack, target.$ref] }, expression); | ||
| return InstantiateType(context, state, returnType); | ||
| const returnType = InstantiateType(argumentsContext, State([...state['callstack'], target['$ref']], state['visited']), expression); | ||
| return InstantiateType(argumentsContext, State([], []), returnType); | ||
| } | ||
@@ -30,0 +31,0 @@ function CallDistributed(context, state, target, parameters, expression, distributedArguments) { |
@@ -6,7 +6,6 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs'; | ||
| import { type TConstructorParametersDeferred } from '../../action/constructor_parameters.mjs'; | ||
| import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TInstantiateElements } from '../instantiate.mjs'; | ||
| type TConstructorParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TConstructor ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, { | ||
| callstack: []; | ||
| }, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result; | ||
| import { type TState } from '../instantiate.mjs'; | ||
| 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; | ||
| export type TConstructorParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TConstructorParametersOperation<Type> : TConstructorParametersDeferred<Type>> = Result; | ||
@@ -13,0 +12,0 @@ export declare function ConstructorParametersAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TConstructorParametersAction<Type>; |
@@ -9,5 +9,6 @@ // deno-lint-ignore-file ban-types | ||
| import { InstantiateElements } from '../instantiate.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| function ConstructorParametersOperation(type) { | ||
| const parameters = IsConstructor(type) ? type['parameters'] : []; | ||
| const instantiatedParameters = InstantiateElements({}, { callstack: [] }, parameters); | ||
| const instantiatedParameters = InstantiateElements({}, State([], []), parameters); | ||
| const result = Tuple(instantiatedParameters); | ||
@@ -14,0 +15,0 @@ return result; |
@@ -9,8 +9,5 @@ import { type TSchema } from '../../types/schema.mjs'; | ||
| import { type TInstantiateTypes } from '../instantiate.mjs'; | ||
| import { type TState } from '../instantiate.mjs'; | ||
| import { type TEvaluateIntersect } from '../evaluate/evaluate.mjs'; | ||
| type TCyclicInterface<Context extends TProperties, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, { | ||
| callstack: []; | ||
| }, Heritage>, instantiatedProperties extends TProperties = TInstantiateProperties<{}, { | ||
| callstack: []; | ||
| }, Properties>, EvaluatedInterface extends TSchema = TEvaluateIntersect<[...InstantiatedHeritage, TObject<instantiatedProperties>]>> = EvaluatedInterface; | ||
| 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; | ||
| type TCyclicDefinitions<Context extends TProperties, Dependencies extends string[], Result extends TProperties = { | ||
@@ -17,0 +14,0 @@ [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]; |
@@ -10,6 +10,7 @@ // deno-lint-ignore-file ban-types | ||
| import { InstantiateTypes } from '../instantiate.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| import { EvaluateIntersect } from '../evaluate/evaluate.mjs'; | ||
| function CyclicInterface(context, heritage, properties) { | ||
| const instantiatedHeritage = InstantiateTypes(context, { callstack: [] }, heritage); | ||
| const instantiatedProperties = InstantiateProperties({}, { callstack: [] }, properties); | ||
| const instantiatedHeritage = InstantiateTypes(context, State([], []), heritage); | ||
| const instantiatedProperties = InstantiateProperties({}, State([], []), properties); | ||
| const evaluatedInterface = EvaluateIntersect([...instantiatedHeritage, Object(instantiatedProperties)]); | ||
@@ -16,0 +17,0 @@ return evaluatedInterface; |
@@ -55,5 +55,7 @@ import { type TImmutable } from '../types/_immutable.mjs'; | ||
| import { type TRestSpread } from './rest/index.mjs'; | ||
| export interface TState { | ||
| callstack: string[]; | ||
| export interface TState<CallStack extends string[] = string[], Visited extends string[] = string[]> { | ||
| callstack: CallStack; | ||
| visited: Visited; | ||
| } | ||
| export declare function State<CallStack extends string[], Visited extends string[]>(callstack: CallStack, visited: Visited): TState<CallStack, Visited>; | ||
| export type TCanInstantiate<Types extends TSchema[]> = Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef ? false : TCanInstantiate<Right> : true; | ||
@@ -162,7 +164,5 @@ export declare function CanInstantiate<Types extends TSchema[]>(types: [...Types]): TCanInstantiate<Types>; | ||
| /** Instantiates computed schematics using the given context and type. */ | ||
| export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, { | ||
| callstack: []; | ||
| }, Type>); | ||
| export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, TState<[], []>, Type>); | ||
| /** Instantiates computed schematics using the given context and type. */ | ||
| export declare function Instantiate<Context extends TProperties, Type extends TSchema>(context: Context, type: Type): TInstantiate<Context, Type>; | ||
| export {}; |
@@ -68,2 +68,5 @@ // deno-fmt-ignore-file | ||
| import { RestSpread } from './rest/index.mjs'; | ||
| export function State(callstack, visited) { | ||
| return { callstack, visited }; | ||
| } | ||
| export function CanInstantiate(types) { | ||
@@ -161,3 +164,3 @@ return Guard.TakeLeft(types, (left, right) => IsRef(left) | ||
| export function Instantiate(context, type) { | ||
| return InstantiateType(context, { callstack: [] }, type); | ||
| return InstantiateType(context, State([], []), type); | ||
| } |
@@ -6,14 +6,11 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs'; | ||
| import { type TInterfaceDeferred } from '../../action/index.mjs'; | ||
| import { type TState, type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TInstantiateProperties } from '../instantiate.mjs'; | ||
| import { type TInstantiateTypes } from '../instantiate.mjs'; | ||
| import { type TState } from '../instantiate.mjs'; | ||
| type TInterfaceOperation<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TEvaluateIntersect<[...Heritage, TObject<Properties>]>> = Result; | ||
| export type TInterfaceAction<Heritage extends TSchema[], Properties extends TProperties, Result extends TSchema = TCanInstantiate<Heritage> extends true ? TInterfaceOperation<Heritage, Properties> : TInterfaceDeferred<Heritage, Properties>> = Result; | ||
| export declare function InterfaceAction<Heritage extends TSchema[], Properties extends TProperties>(heritage: [...Heritage], properties: Properties, options: TSchemaOptions): TInterfaceAction<Heritage, Properties>; | ||
| export type TInterfaceInstantiate<Context extends TProperties, State extends TState, Heritage extends TSchema[], Properties extends TProperties, InstantiatedHeritage extends TSchema[] = TInstantiateTypes<Context, { | ||
| callstack: []; | ||
| }, Heritage>, InstantiatedProperties extends TProperties = TInstantiateProperties<Context, { | ||
| callstack: []; | ||
| }, Properties>> = TInterfaceAction<InstantiatedHeritage, InstantiatedProperties>; | ||
| 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>; | ||
| 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>; | ||
| export {}; |
@@ -12,5 +12,3 @@ import { Memory } from '../../../system/memory/index.mjs'; | ||
| type TInstantiateNonCyclics<Context extends TProperties, CyclicKeys extends string[], Result extends TProperties = { | ||
| [Key in Exclude<keyof Context, CyclicKeys[number]>]: TInstantiateType<Context, { | ||
| callstack: []; | ||
| }, Context[Key]>; | ||
| [Key in Exclude<keyof Context, CyclicKeys[number]>]: TInstantiateType<Context, TState<[], []>, Context[Key]>; | ||
| }> = Result; | ||
@@ -17,0 +15,0 @@ 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> = { |
@@ -5,2 +5,3 @@ // deno-lint-ignore-file ban-types | ||
| import { Memory } from '../../../system/memory/index.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| // ------------------------------------------------------------------ | ||
@@ -21,3 +22,3 @@ // Module: Instantiation Infrastructure | ||
| return keys.reduce((result, key) => { | ||
| return { ...result, [key]: InstantiateType(context, { callstack: [] }, context[key]) }; | ||
| return { ...result, [key]: InstantiateType(context, State([], []), context[key]) }; | ||
| }, {}); | ||
@@ -24,0 +25,0 @@ } |
@@ -6,7 +6,6 @@ import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs'; | ||
| import { type TParametersDeferred } from '../../action/parameters.mjs'; | ||
| import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs'; | ||
| import { type TInstantiateElements } from '../instantiate.mjs'; | ||
| type TParametersOperation<Type extends TSchema, Parameters extends TSchema[] = Type extends TFunction ? Type['parameters'] : [], InstantiatedParameters extends TSchema[] = TInstantiateElements<{}, { | ||
| callstack: []; | ||
| }, Parameters>, Result extends TSchema = TTuple<InstantiatedParameters>> = Result; | ||
| import { type TState } from '../instantiate.mjs'; | ||
| 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; | ||
| export type TParametersAction<Type extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TParametersOperation<Type> : TParametersDeferred<Type>> = Result; | ||
@@ -13,0 +12,0 @@ export declare function ParametersAction<Type extends TSchema>(type: Type, options: TSchemaOptions): TParametersAction<Type>; |
@@ -9,5 +9,6 @@ // deno-lint-ignore-file ban-types | ||
| import { InstantiateElements } from '../instantiate.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| function ParametersOperation(type) { | ||
| const parameters = IsFunction(type) ? type['parameters'] : []; | ||
| const instantiatedParameters = InstantiateElements({}, { callstack: [] }, parameters); | ||
| const instantiatedParameters = InstantiateElements({}, State([], []), parameters); | ||
| const result = Tuple(instantiatedParameters); | ||
@@ -14,0 +15,0 @@ return result; |
| import { type TProperties } from '../../types/properties.mjs'; | ||
| import { type TState, type TInstantiateType } from '../instantiate.mjs'; | ||
| import { type TCyclicCheck } from '../cyclic/check.mjs'; | ||
| import { type TInstantiateType } from '../instantiate.mjs'; | ||
| import { type TRef } from '../../types/ref.mjs'; | ||
| export type TRefInstantiate<Context extends TProperties, State extends TState, Type extends TRef, Ref extends string> = (Ref extends keyof Context ? TCyclicCheck<[Ref], Context, Context[Ref]> extends true ? Type : TInstantiateType<Context, State, Context[Ref]> : Type); | ||
| import { type TState } from '../instantiate.mjs'; | ||
| 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); | ||
| 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>; |
| // deno-fmt-ignore-file | ||
| import { InstantiateType } from '../instantiate.mjs'; | ||
| import { CyclicCheck } from '../cyclic/check.mjs'; | ||
| import { State } from '../instantiate.mjs'; | ||
| export function RefInstantiate(context, state, type, ref) { | ||
| return (ref in context | ||
| ? CyclicCheck([ref], context, context[ref]) | ||
| ? type | ||
| : InstantiateType(context, state, context[ref]) | ||
| : type); | ||
| return (state.visited.includes(ref) | ||
| ? type | ||
| : ref in context | ||
| ? InstantiateType(context, State(state['callstack'], [...state['visited'], ref]), context[ref]) | ||
| : type); | ||
| } |
@@ -9,2 +9,3 @@ import { type TSchema } from '../types/schema.mjs'; | ||
| import { type TInstantiateElements } from '../engine/instantiate.mjs'; | ||
| import { type TState } from '../engine/instantiate.mjs'; | ||
| import { type TTryRestInferable, type TTryInferable, type TInferable, type TInferTupleResult, type TInferUnionResult } from './inference.mjs'; | ||
@@ -18,10 +19,6 @@ type TReverse<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TReverse<Right, [Left, ...Result]> : Result); | ||
| type TElements<Inferred extends TProperties, Reversed extends boolean, LeftRest extends TSchema[], RightRest extends TSchema[]> = TElementsRight<Inferred, Reversed, LeftRest, RightRest>; | ||
| type TExtendsTupleToTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema[], InstantiatedRight extends TSchema[] = TInstantiateElements<Inferred, { | ||
| callstack: []; | ||
| }, Right>, Reversed extends boolean = TReversed<InstantiatedRight>> = TElements<Inferred, Reversed, TApplyReverse<Left, Reversed>, TApplyReverse<InstantiatedRight, Reversed>>; | ||
| 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>>; | ||
| 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>); | ||
| export type TExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema, InstantiatedLeft extends TSchema[] = TInstantiateElements<Inferred, { | ||
| callstack: []; | ||
| }, 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>); | ||
| 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>); | ||
| export declare function ExtendsTuple<Inferred extends TProperties, Left extends TSchema[], Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsTuple<Inferred, Left, Right>; | ||
| export {}; |
@@ -10,2 +10,3 @@ // deno-fmt-ignore-file | ||
| import { InstantiateElements } from '../engine/instantiate.mjs'; | ||
| import { State } from '../engine/instantiate.mjs'; | ||
| // ---------------------------------------------------------------------------- | ||
@@ -46,3 +47,3 @@ // Inference | ||
| function ExtendsTupleToTuple(inferred, left, right) { | ||
| const instantiatedRight = InstantiateElements(inferred, { callstack: [] }, right); | ||
| const instantiatedRight = InstantiateElements(inferred, State([], []), right); | ||
| const reversed = Reversed(instantiatedRight); | ||
@@ -58,3 +59,3 @@ return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed)); | ||
| export function ExtendsTuple(inferred, left, right) { | ||
| const instantiatedLeft = InstantiateElements(inferred, { callstack: [] }, left); | ||
| const instantiatedLeft = InstantiateElements(inferred, State([], []), left); | ||
| return (IsTuple(right) ? ExtendsTupleToTuple(inferred, instantiatedLeft, right.items) : | ||
@@ -61,0 +62,0 @@ IsArray(right) ? ExtendsTupleToArray(inferred, instantiatedLeft, right.items) : |
| import type { TArrayOptions, TIntersectOptions, TNumberOptions, TObjectOptions, TStringOptions, TTupleOptions } from '../../type/index.mjs'; | ||
| import { type TNever, type TSchema, type TProperties } from '../types/index.mjs'; | ||
| import { type TInstantiateType } from '../engine/instantiate.mjs'; | ||
| import { type TNever, type TSchema, type TProperties } from '../types/index.mjs'; | ||
| import { type TState } from '../engine/instantiate.mjs'; | ||
| import * as Parser from './parser.mjs'; | ||
| export type TScriptOptions = TArrayOptions | TIntersectOptions | TNumberOptions | TObjectOptions | TStringOptions | TTupleOptions; | ||
| /** Parses a string-based TypeScript type expression into a TypeBox type. */ | ||
| export type TScript<Context extends TProperties, Input extends string> = (Parser.TScript<Input> extends [infer Type extends TSchema, string] ? TInstantiateType<Context, { | ||
| callstack: []; | ||
| }, Type> : TNever); | ||
| export type TScript<Context extends TProperties, Input extends string> = (Parser.TScript<Input> extends [infer Type extends TSchema, string] ? TInstantiateType<Context, TState<[], []>, Type> : TNever); | ||
| /** Parses a type from a TypeScript type expression */ | ||
@@ -11,0 +10,0 @@ export declare function Script<Script extends string>(input: Script): TScript<{}, Script>; |
@@ -6,4 +6,5 @@ // deno-lint-ignore-file | ||
| import { Guard } from '../../guard/index.mjs'; | ||
| import { Never } from '../types/index.mjs'; | ||
| import { InstantiateType } from '../engine/instantiate.mjs'; | ||
| import { Never } from '../types/index.mjs'; | ||
| import { State } from '../engine/instantiate.mjs'; | ||
| import * as Parser from './parser.mjs'; | ||
@@ -19,5 +20,5 @@ /** Parses a type from a TypeScript type expression */ | ||
| const parsed = Guard.IsArray(result) && Guard.IsEqual(result.length, 2) | ||
| ? InstantiateType(context, { callstack: [] }, result[0]) | ||
| ? InstantiateType(context, State([], []), result[0]) | ||
| : Never(); | ||
| return Memory.Update(parsed, {}, options); | ||
| } |
| import { type TSchema } from './schema.mjs'; | ||
| import { type TCallInstantiate } from '../engine/call/instantiate.mjs'; | ||
| import { type TState } from '../engine/instantiate.mjs'; | ||
| /** Represents a deferred generic Call */ | ||
| export interface TCall<Target extends TSchema = TSchema, Arguments extends TSchema[] = TSchema[]> extends TSchema { | ||
| '~kind': 'Call'; | ||
| type: 'call'; | ||
| target: Target; | ||
@@ -12,6 +14,4 @@ arguments: Arguments; | ||
| /** Creates a Call type. */ | ||
| export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{}, { | ||
| callstack: []; | ||
| }, Target, Arguments>; | ||
| export declare function Call<Target extends TSchema, Arguments extends TSchema[]>(target: Target, arguments_: [...Arguments]): TCallInstantiate<{}, TState<[], []>, Target, Arguments>; | ||
| /** Returns true if the given type is a TCall. */ | ||
| export declare function IsCall(value: unknown): value is TCall; |
@@ -6,4 +6,5 @@ // deno-lint-ignore-file ban-types | ||
| import { CallInstantiate } from '../engine/call/instantiate.mjs'; | ||
| import { State } from '../engine/instantiate.mjs'; | ||
| export function CallConstruct(target, arguments_) { | ||
| return Memory.Create({ ['~kind']: 'Call' }, { target, arguments: arguments_ }, {}); | ||
| return Memory.Create({ ['~kind']: 'Call' }, { type: 'call', target, arguments: arguments_ }, {}); | ||
| } | ||
@@ -15,3 +16,3 @@ // ------------------------------------------------------------------ | ||
| export function Call(target, arguments_) { | ||
| return CallInstantiate({}, { callstack: [] }, target, arguments_); | ||
| return CallInstantiate({}, State([], []), target, arguments_); | ||
| } | ||
@@ -18,0 +19,0 @@ // ------------------------------------------------------------------ |
+1
-1
| { | ||
| "name": "typebox", | ||
| "description": "Json Schema Type Builder with Static Type Resolution for TypeScript", | ||
| "version": "1.2.2", | ||
| "version": "1.2.3", | ||
| "keywords": [ | ||
@@ -6,0 +6,0 @@ "typescript", |
1486356
0.08%17069
0.08%