Skip to content

Commit 47d9e21

Browse files
committed
updates
1 parent a51f3c8 commit 47d9e21

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/type/engine/instantiate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { type TDeferred, Deferred, IsDeferred } from '../types/deferred.ts'
5050
import { type TFunction, _Function_, IsFunction, FunctionOptions } from '../types/function.ts'
5151
import { type TCall, IsCall } from '../types/call.ts'
5252
import { type TIdentifier } from '../types/identifier.ts'
53+
import { type TIf, If, IsIf, IfOptions } from '../types/if.ts'
5354
import { type TIntersect, Intersect, IsIntersect, IntersectOptions } from '../types/intersect.ts'
5455
import { type TIterator, Iterator, IsIterator, IteratorOptions } from '../types/iterator.ts'
5556
import { type TObject, Object, IsObject, ObjectOptions } from '../types/object.ts'
@@ -305,9 +306,10 @@ export type TInstantiateType<Context extends TProperties, State extends TState,
305306
Type extends TArray<infer Type extends TSchema> ? TArray<TInstantiateType<Context, State, Type>> :
306307
Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TInstantiateType<Context, State, Type>> :
307308
Type extends TCall<infer Target extends TSchema, infer Parameters extends TSchema[]> ? TCallInstantiate<Context, State, Target, Parameters> :
308-
Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State,Parameters>, TInstantiateType<Context, State,InstanceType>> :
309+
Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TInstantiateTypes<Context, State,Parameters>, TInstantiateType<Context, State, InstanceType>> :
309310
Type extends TDeferred<infer Action extends string, infer Types extends TSchema[]> ? TInstantiateDeferred<Context, State, Action, Types> :
310311
Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TInstantiateTypes<Context, State, Parameters>, TInstantiateType<Context, State,ReturnType>> :
312+
Type extends TIf<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TIf<TInstantiateType<Context, State, If>, TInstantiateType<Context, State, Then>, TInstantiateType<Context, State, Else>> :
311313
Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TInstantiateTypes<Context, State, Types>> :
312314
Type extends TIterator<infer Type extends TSchema> ? TIterator<TInstantiateType<Context, State, Type>> :
313315
Type extends TObject<infer Properties extends TProperties> ? TObject<TInstantiateProperties<Context, State, Properties>> :
@@ -338,6 +340,7 @@ export function InstantiateType<Context extends TProperties, State extends TStat
338340
IsConstructor(type) ? Constructor(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.instanceType) as never, ConstructorOptions(type)) :
339341
IsDeferred(type) ? InstantiateDeferred(context, state, type.action, type.parameters, type.options) :
340342
IsFunction(type) ? _Function_(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.returnType) as never, FunctionOptions(type)) :
343+
IsIf(type) ? If(InstantiateType(context, state, type.if), InstantiateType(context, state, type.then), InstantiateType(context, state, type.else), IfOptions(type)) :
341344
IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) :
342345
IsIterator(type) ? Iterator(InstantiateType(context, state, type.iteratorItems), IteratorOptions(type)) :
343346
IsObject(type) ? Object(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) :

src/type/script/mapping.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,16 +1214,16 @@ export type T_If_Mapping<Input extends [unknown, unknown, unknown, unknown, unkn
12141214
Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema, 'else', infer Else extends T.TSchema]
12151215
? T.TIf<If, Then, Else> :
12161216
Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema]
1217-
? T.TIf<If, Then, T.TNever> :
1217+
? T.TIf<If, Then, T.TUnknown> :
12181218
Input extends ['if', infer If extends T.TSchema, 'else', infer Else extends T.TSchema]
1219-
? T.TIf<If, T.TNever, Else> :
1219+
? T.TIf<If, T.TUnknown, Else> :
12201220
never
12211221
)
12221222
export function _If_Mapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]): unknown {
12231223
return (
12241224
Guard.IsEqual(input.length, 6) ? T.If(input[1] as T.TSchema, input[3] as T.TSchema, input[5] as T.TSchema) :
1225-
Guard.IsEqual(input[2], 'then') ? T.If(input[1] as T.TSchema, input[3] as T.TSchema, T.Never()) :
1226-
T.If(input[1] as T.TSchema, T.Never(), input[3] as T.TSchema)
1225+
Guard.IsEqual(input[2], 'then') ? T.If(input[1] as T.TSchema, input[3] as T.TSchema, T.Unknown()) :
1226+
T.If(input[1] as T.TSchema, T.Unknown(), input[3] as T.TSchema)
12271227
)
12281228
}
12291229
// -------------------------------------------------------------------

0 commit comments

Comments
 (0)