typebox 1.1.38 → 1.2.0
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/guard/guard.d.mts +2 -2
- package/build/guard/guard.mjs +2 -2
- package/build/type/action/index.d.mts +1 -1
- package/build/type/action/index.mjs +1 -1
- package/build/type/action/with.d.mts +21 -0
- package/build/type/action/with.mjs +19 -0
- package/build/type/engine/enum/index.d.mts +0 -1
- package/build/type/engine/enum/index.mjs +0 -1
- package/build/type/engine/evaluate/evaluate.d.mts +15 -3
- package/build/type/engine/evaluate/evaluate.mjs +30 -6
- package/build/type/engine/exclude/operation.d.mts +5 -6
- package/build/type/engine/exclude/operation.mjs +11 -12
- package/build/type/engine/extract/operation.d.mts +5 -6
- package/build/type/engine/extract/operation.mjs +11 -12
- package/build/type/engine/index.d.mts +1 -1
- package/build/type/engine/index.mjs +1 -1
- package/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/build/type/engine/indexable/from_enum.mjs +4 -4
- package/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/build/type/engine/indexable/from_type.d.mts +3 -1
- package/build/type/engine/indexable/from_type.mjs +9 -6
- package/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/build/type/engine/indexed/instantiate.mjs +2 -1
- package/build/type/engine/instantiate.d.mts +7 -6
- package/build/type/engine/instantiate.mjs +23 -21
- package/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/build/type/engine/keyof/instantiate.mjs +2 -1
- package/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/build/type/engine/object/from_dependent.d.mts +5 -0
- package/build/type/engine/object/from_dependent.mjs +8 -0
- package/build/type/engine/object/from_type.d.mts +3 -1
- package/build/type/engine/object/from_type.mjs +8 -5
- package/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/build/type/engine/partial/from_dependent.mjs +8 -0
- package/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/build/type/engine/partial/from_intersect.mjs +3 -2
- package/build/type/engine/partial/from_type.d.mts +3 -1
- package/build/type/engine/partial/from_type.mjs +7 -4
- package/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/build/type/engine/record/from_key_enum.mjs +2 -2
- package/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/build/type/engine/required/from_dependent.d.mts +5 -0
- package/build/type/engine/required/from_dependent.mjs +8 -0
- package/build/type/engine/required/from_intersect.d.mts +1 -1
- package/build/type/engine/required/from_intersect.mjs +3 -2
- package/build/type/engine/required/from_type.d.mts +3 -1
- package/build/type/engine/required/from_type.mjs +7 -4
- package/build/type/engine/template_literal/encode.d.mts +2 -2
- package/build/type/engine/template_literal/encode.mjs +4 -4
- package/build/type/engine/with/instantiate.d.mts +8 -0
- package/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/build/type/extends/dependent.d.mts +6 -0
- package/build/type/extends/dependent.mjs +6 -0
- package/build/type/extends/enum.d.mts +4 -4
- package/build/type/extends/enum.mjs +3 -2
- package/build/type/extends/extends_left.d.mts +3 -1
- package/build/type/extends/extends_left.mjs +23 -20
- package/build/type/extends/extends_right.d.mts +7 -5
- package/build/type/extends/extends_right.mjs +18 -13
- package/build/type/extends/template_literal.d.mts +3 -3
- package/build/type/extends/template_literal.mjs +3 -3
- package/build/type/script/mapping.d.mts +7 -7
- package/build/type/script/mapping.mjs +30 -23
- package/build/type/script/parser.d.mts +6 -4
- package/build/type/script/parser.mjs +4 -3
- package/build/type/types/dependent.d.mts +17 -0
- package/build/type/types/dependent.mjs +24 -0
- package/build/type/types/enum.d.mts +1 -1
- package/build/type/types/index.d.mts +1 -0
- package/build/type/types/index.mjs +1 -0
- package/build/type/types/static.d.mts +2 -1
- package/build/typebox.d.mts +2 -1
- package/build/typebox.mjs +2 -1
- package/build/value/clean/from_intersect.mjs +2 -2
- package/build/value/clone/clone.mjs +17 -3
- package/build/value/convert/from_enum.mjs +3 -4
- package/build/value/convert/from_template_literal.d.mts +1 -1
- package/build/value/convert/from_template_literal.mjs +2 -3
- package/build/value/create/from_enum.mjs +2 -2
- package/build/value/repair/from_enum.mjs +2 -3
- package/package.json +29 -29
- package/readme.md +51 -20
- package/build/type/action/options.d.mts +0 -11
- package/build/type/action/options.mjs +0 -11
- package/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/build/type/engine/options/instantiate.d.mts +0 -8
- /package/build/type/engine/{options → with}/index.d.mts +0 -0
- /package/build/type/engine/{options → with}/index.mjs +0 -0
package/build/guard/guard.d.mts
CHANGED
|
@@ -59,9 +59,9 @@ export declare function HasPropertyKey<Key extends PropertyKey>(value: object, k
|
|
|
59
59
|
export declare function EntriesRegExp<Value extends unknown = unknown>(value: Record<PropertyKey, Value>): [RegExp, Value][];
|
|
60
60
|
/** Returns object entries as `[string, Value][]` */
|
|
61
61
|
export declare function Entries<Value extends unknown = unknown>(value: Record<PropertyKey, Value>): [string, Value][];
|
|
62
|
-
/** Returns property keys for this object via `Object.
|
|
62
|
+
/** Returns property keys for this object via `Object.getOwnPropertyNames({ ... })` */
|
|
63
63
|
export declare function Keys(value: Record<PropertyKey, unknown>): string[];
|
|
64
|
-
/** Returns the property keys for this object via `Object.
|
|
64
|
+
/** Returns the property keys for this object via `Object.getOwnPropertySymbols({ ... })` */
|
|
65
65
|
export declare function Symbols(value: Record<PropertyKey, unknown>): symbol[];
|
|
66
66
|
/** Returns the property values for the given object via `Object.values()` */
|
|
67
67
|
export declare function Values(value: Record<PropertyKey, unknown>): unknown[];
|
package/build/guard/guard.mjs
CHANGED
|
@@ -185,11 +185,11 @@ export function EntriesRegExp(value) {
|
|
|
185
185
|
export function Entries(value) {
|
|
186
186
|
return Object.entries(value);
|
|
187
187
|
}
|
|
188
|
-
/** Returns property keys for this object via `Object.
|
|
188
|
+
/** Returns property keys for this object via `Object.getOwnPropertyNames({ ... })` */
|
|
189
189
|
export function Keys(value) {
|
|
190
190
|
return Object.getOwnPropertyNames(value);
|
|
191
191
|
}
|
|
192
|
-
/** Returns the property keys for this object via `Object.
|
|
192
|
+
/** Returns the property keys for this object via `Object.getOwnPropertySymbols({ ... })` */
|
|
193
193
|
export function Symbols(value) {
|
|
194
194
|
return Object.getOwnPropertySymbols(value);
|
|
195
195
|
}
|
|
@@ -16,7 +16,6 @@ export * from './mapped.mjs';
|
|
|
16
16
|
export * from './module.mjs';
|
|
17
17
|
export * from './non_nullable.mjs';
|
|
18
18
|
export * from './omit.mjs';
|
|
19
|
-
export * from './options.mjs';
|
|
20
19
|
export * from './parameters.mjs';
|
|
21
20
|
export * from './partial.mjs';
|
|
22
21
|
export * from './pick.mjs';
|
|
@@ -25,3 +24,4 @@ export * from './required.mjs';
|
|
|
25
24
|
export * from './return_type.mjs';
|
|
26
25
|
export * from './uncapitalize.mjs';
|
|
27
26
|
export * from './uppercase.mjs';
|
|
27
|
+
export * from './with.mjs';
|
|
@@ -16,7 +16,6 @@ export * from './mapped.mjs';
|
|
|
16
16
|
export * from './module.mjs';
|
|
17
17
|
export * from './non_nullable.mjs';
|
|
18
18
|
export * from './omit.mjs';
|
|
19
|
-
export * from './options.mjs';
|
|
20
19
|
export * from './parameters.mjs';
|
|
21
20
|
export * from './partial.mjs';
|
|
22
21
|
export * from './pick.mjs';
|
|
@@ -25,3 +24,4 @@ export * from './required.mjs';
|
|
|
25
24
|
export * from './return_type.mjs';
|
|
26
25
|
export * from './uncapitalize.mjs';
|
|
27
26
|
export * from './uppercase.mjs';
|
|
27
|
+
export * from './with.mjs';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TSchema } from '../types/schema.mjs';
|
|
2
|
+
import { type TDeferred } from '../types/deferred.mjs';
|
|
3
|
+
import { type TWithAction } from '../engine/with/instantiate.mjs';
|
|
4
|
+
/** Creates a deferred With action. */
|
|
5
|
+
export type TWithDeferred<Type extends TSchema, Options extends TSchema> = (TDeferred<'With', [Type, Options]>);
|
|
6
|
+
/** Creates a deferred With action. */
|
|
7
|
+
export declare function WithDeferred<Type extends TSchema, Options extends TSchema>(type: Type, options: Options): TWithDeferred<Type, Options>;
|
|
8
|
+
/** Applies annotation options to the given type. */
|
|
9
|
+
export type TWith<Type extends TSchema, Options extends TSchema> = (Type & Options);
|
|
10
|
+
/** Applies annotation options to the given type. */
|
|
11
|
+
export declare function With<Type extends TSchema, const Options extends TSchema>(type: Type, options: Options): TWithAction<Type, Options>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Type.TOptions\<T\> has been renamed to Type.TWith\<T\>. This type will be removed in the
|
|
14
|
+
* next version of TypeBox.
|
|
15
|
+
*/
|
|
16
|
+
export type TOptions<Type extends TSchema, Options extends TSchema> = TWith<Type, Options>;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Type.Options\<T\> has been renamed to Type.With\<T\>. This type will be removed in the
|
|
19
|
+
* next version of TypeBox.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Options<Type extends TSchema, const Options extends TSchema>(type: Type, options: Options): TOptions<Type, Options>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Deferred } from '../types/deferred.mjs';
|
|
3
|
+
import { WithAction } from '../engine/with/instantiate.mjs';
|
|
4
|
+
/** Creates a deferred With action. */
|
|
5
|
+
export function WithDeferred(type, options) {
|
|
6
|
+
return Deferred('With', [type, options], {});
|
|
7
|
+
}
|
|
8
|
+
/** Applies annotation options to the given type. */
|
|
9
|
+
export function With(type, options) {
|
|
10
|
+
return WithAction(type, options);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Type.Options\<T\> has been renamed to Type.With\<T\>. This type will be removed in the
|
|
14
|
+
* next version of TypeBox.
|
|
15
|
+
*/
|
|
16
|
+
export function Options(type, options) {
|
|
17
|
+
return With(type, options);
|
|
18
|
+
}
|
|
19
|
+
// deno-coverage-ignore-stop
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TDependent } from '../../types/dependent.mjs';
|
|
3
|
+
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
4
|
+
import { type TLiteral } from '../../types/literal.mjs';
|
|
2
5
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
6
|
+
import { type TNever } from '../../types/never.mjs';
|
|
7
|
+
import { type TTemplateLiteral } from '../../types/template_literal.mjs';
|
|
8
|
+
import { type TUnion } from '../../types/union.mjs';
|
|
3
9
|
import { type TDistribute } from './distribute.mjs';
|
|
4
10
|
import { type TBroaden } from './broaden.mjs';
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
11
|
+
import { type TExcludeOperation } from '../exclude/operation.mjs';
|
|
12
|
+
import { type TTemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
13
|
+
export type TEvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema, Intersect extends TSchema = TIntersect<[If, Then]>, Excluded extends TSchema = TExcludeOperation<Else, If>, Result extends TSchema = TEvaluateUnion<[Intersect, Excluded]>> = Result;
|
|
14
|
+
export declare function EvaluateDependent<If extends TSchema, Then extends TSchema, Else extends TSchema>(if_: If, then_: Then, else_: Else): TEvaluateDependent<If, Then, Else>;
|
|
15
|
+
export type TEvaluateEnum<Values extends TEnumValue[], Result extends TSchema[] = []> = (Values extends [infer Left extends TEnumValue, ...infer Right extends TEnumValue[]] ? TEvaluateEnum<Right, [...Result, TLiteral<Left>]> : TEvaluateUnion<Result>);
|
|
16
|
+
export declare function EvaluateEnum<Values extends TEnumValue[]>(values: [...Values]): TEvaluateEnum<Values>;
|
|
7
17
|
export type TEvaluateIntersect<Types extends TSchema[], Distribution extends TSchema[] = TDistribute<Types>, Result extends TSchema = TBroaden<Distribution>> = Result;
|
|
8
18
|
export declare function EvaluateIntersect<Types extends TSchema[]>(types: [...Types]): TEvaluateIntersect<Types>;
|
|
19
|
+
export type TEvaluateTemplateLiteral<Pattern extends string, Evaluated extends TSchema = TTemplateLiteralDecode<Pattern>, Result extends TSchema = TEvaluateType<Evaluated>> = Result;
|
|
20
|
+
export declare function EvaluateTemplateLiteral<Pattern extends string>(pattern: Pattern): TEvaluateTemplateLiteral<Pattern>;
|
|
9
21
|
export type TEvaluateUnion<Types extends TSchema[], Result extends TSchema = TBroaden<Types>> = Result;
|
|
10
22
|
export declare function EvaluateUnion<Types extends TSchema[]>(types: [...Types]): TEvaluateUnion<Types>;
|
|
11
|
-
export type TEvaluateType<Type extends TSchema, Result extends TSchema = (Type extends TIntersect<infer Types extends TSchema[]> ? TEvaluateIntersect<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TEvaluateUnion<Types> : Type)> = Result;
|
|
23
|
+
export type TEvaluateType<Type extends TSchema, Result extends TSchema = (Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TEvaluateDependent<If, Then, Else> : Type extends TEnum<infer Values extends TEnumValue[]> ? TEvaluateEnum<Values> : Type extends TIntersect<infer Types extends TSchema[]> ? TEvaluateIntersect<Types> : Type extends TTemplateLiteral<infer Pattern extends string> ? TEvaluateTemplateLiteral<Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEvaluateUnion<Types> : Type)> = Result;
|
|
12
24
|
export declare function EvaluateType<Type extends TSchema>(type: Type): TEvaluateType<Type>;
|
|
13
25
|
export type TEvaluateUnionFast<Types extends TSchema[], Result extends TSchema = (Types extends [infer Type extends TSchema] ? Type : Types extends [] ? TNever : TUnion<Types>)> = Result;
|
|
14
26
|
export declare function EvaluateUnionFast<Types extends TSchema[]>(types: [...Types]): TEvaluateUnionFast<Types>;
|
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Guard } from '../../../guard/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { IsDependent } from '../../types/dependent.mjs';
|
|
4
|
+
import { IsEnum } from '../../types/enum.mjs';
|
|
5
|
+
import { Literal } from '../../types/literal.mjs';
|
|
6
|
+
import { IsIntersect, Intersect } from '../../types/intersect.mjs';
|
|
7
|
+
import { Never } from '../../types/never.mjs';
|
|
8
|
+
import { IsTemplateLiteral } from '../../types/template_literal.mjs';
|
|
9
|
+
import { Union, IsUnion } from '../../types/union.mjs';
|
|
4
10
|
import { Distribute } from './distribute.mjs';
|
|
5
11
|
import { Broaden } from './broaden.mjs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
12
|
+
import { ExcludeOperation } from '../exclude/operation.mjs';
|
|
13
|
+
import { TemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
14
|
+
export function EvaluateDependent(if_, then_, else_) {
|
|
15
|
+
const intersect = Intersect([if_, then_]);
|
|
16
|
+
const excluded = ExcludeOperation(else_, if_);
|
|
17
|
+
const result = EvaluateUnion([intersect, excluded]);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
export function EvaluateEnum(values) {
|
|
21
|
+
const result = values.map(value => Literal(value));
|
|
22
|
+
return EvaluateUnion(result);
|
|
23
|
+
}
|
|
8
24
|
export function EvaluateIntersect(types) {
|
|
9
25
|
const distribution = Distribute(types);
|
|
10
26
|
const result = Broaden(distribution);
|
|
11
27
|
return result;
|
|
12
28
|
}
|
|
29
|
+
export function EvaluateTemplateLiteral(pattern) {
|
|
30
|
+
const evaluated = TemplateLiteralDecode(pattern);
|
|
31
|
+
const result = EvaluateType(evaluated);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
13
34
|
export function EvaluateUnion(types) {
|
|
14
35
|
const result = Broaden(types);
|
|
15
36
|
return result;
|
|
16
37
|
}
|
|
17
38
|
export function EvaluateType(type) {
|
|
18
|
-
return (
|
|
19
|
-
|
|
20
|
-
type)
|
|
39
|
+
return (IsDependent(type) ? EvaluateDependent(type.if, type.then, type.else) :
|
|
40
|
+
IsEnum(type) ? EvaluateEnum(type.enum) :
|
|
41
|
+
IsIntersect(type) ? EvaluateIntersect(type.allOf) :
|
|
42
|
+
IsTemplateLiteral(type) ? EvaluateTemplateLiteral(type.pattern) :
|
|
43
|
+
IsUnion(type) ? EvaluateUnion(type.anyOf) :
|
|
44
|
+
type);
|
|
21
45
|
}
|
|
22
46
|
export function EvaluateUnionFast(types) {
|
|
23
47
|
const result = (Guard.IsEqual(types.length, 1) ? types[0] :
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
-
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
3
2
|
import { type TUnion } from '../../types/union.mjs';
|
|
4
3
|
import { type TExtends, ExtendsResult } from '../../extends/index.mjs';
|
|
5
|
-
import { type
|
|
6
|
-
import { type TEvaluateUnion
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
export type TExcludeOperation<Left extends TSchema, Right extends TSchema,
|
|
4
|
+
import { type TEvaluateType } from '../evaluate/evaluate.mjs';
|
|
5
|
+
import { type TEvaluateUnion } from '../evaluate/evaluate.mjs';
|
|
6
|
+
type TExcludeType<Left extends TSchema, Right extends TSchema, Check extends ExtendsResult.TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends ExtendsResult.TExtendsTrueLike ? [] : [Left]> = Result;
|
|
7
|
+
type TExcludeUnion<Left extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExcludeUnion<Tail, Right, [...Result, ...TExcludeType<Head, Right>]> : Result);
|
|
8
|
+
export type TExcludeOperation<Left extends TSchema, Right extends TSchema, Evaluated extends TSchema = TEvaluateType<Left>, Canonical extends TSchema[] = Evaluated extends TUnion<infer Types extends TSchema[]> ? Types : [Evaluated], Remaining extends TSchema[] = TExcludeUnion<Canonical, Right>, Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
10
9
|
export declare function ExcludeOperation<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TExcludeOperation<Left, Right>;
|
|
11
10
|
export {};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
|
-
import { IsEnum } from '../../types/enum.mjs';
|
|
4
3
|
import { IsUnion } from '../../types/union.mjs';
|
|
5
4
|
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
6
|
-
import {
|
|
7
|
-
import { EvaluateUnion
|
|
8
|
-
function
|
|
9
|
-
return types.reduce((result, head) => {
|
|
10
|
-
return [...result, ...ExcludeTypeLeft(head, right)];
|
|
11
|
-
}, []);
|
|
12
|
-
}
|
|
13
|
-
function ExcludeTypeLeft(left, right) {
|
|
5
|
+
import { EvaluateType } from '../evaluate/evaluate.mjs';
|
|
6
|
+
import { EvaluateUnion } from '../evaluate/evaluate.mjs';
|
|
7
|
+
function ExcludeType(left, right) {
|
|
14
8
|
const check = Extends({}, left, right);
|
|
15
9
|
const result = ExtendsResult.IsExtendsTrueLike(check) ? [] : [left];
|
|
16
10
|
return result;
|
|
17
11
|
}
|
|
12
|
+
function ExcludeUnion(types, right) {
|
|
13
|
+
return types.reduce((result, head) => {
|
|
14
|
+
return [...result, ...ExcludeType(head, right)];
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
18
17
|
export function ExcludeOperation(left, right) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const evaluated = EvaluateType(left);
|
|
19
|
+
const canonical = IsUnion(evaluated) ? evaluated.anyOf : [evaluated];
|
|
20
|
+
const remaining = ExcludeUnion(canonical, right);
|
|
22
21
|
const result = EvaluateUnion(remaining);
|
|
23
22
|
return result;
|
|
24
23
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
-
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
3
2
|
import { type TUnion } from '../../types/union.mjs';
|
|
4
3
|
import { type TExtends, ExtendsResult } from '../../extends/index.mjs';
|
|
5
|
-
import { type
|
|
6
|
-
import { type TEvaluateUnion
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
export type TExtractOperation<Left extends TSchema, Right extends TSchema,
|
|
4
|
+
import { type TEvaluateType } from '../evaluate/evaluate.mjs';
|
|
5
|
+
import { type TEvaluateUnion } from '../evaluate/evaluate.mjs';
|
|
6
|
+
type TExtractType<Left extends TSchema, Right extends TSchema, Check extends ExtendsResult.TResult = TExtends<{}, Left, Right>, Result extends TSchema[] = Check extends ExtendsResult.TExtendsTrueLike ? [Left] : []> = Result;
|
|
7
|
+
type TExtractUnion<Types extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Types extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtractUnion<Tail, Right, [...Result, ...TExtractType<Head, Right>]> : Result);
|
|
8
|
+
export type TExtractOperation<Left extends TSchema, Right extends TSchema, Evaluated extends TSchema = TEvaluateType<Left>, Canonical extends TSchema[] = Evaluated extends TUnion<infer Types extends TSchema[]> ? Types : [Evaluated], Remaining extends TSchema[] = TExtractUnion<Canonical, Right>, Result extends TSchema = TEvaluateUnion<Remaining>> = Result;
|
|
10
9
|
export declare function ExtractOperation<Left extends TSchema, Right extends TSchema>(left: Left, right: Right): TExtractOperation<Left, Right>;
|
|
11
10
|
export {};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
3
|
-
import { IsEnum } from '../../types/enum.mjs';
|
|
4
3
|
import { IsUnion } from '../../types/union.mjs';
|
|
5
4
|
import { Extends, ExtendsResult } from '../../extends/index.mjs';
|
|
6
|
-
import {
|
|
7
|
-
import { EvaluateUnion
|
|
8
|
-
function
|
|
9
|
-
return types.reduce((result, head) => {
|
|
10
|
-
return [...result, ...ExtractTypeLeft(head, right)];
|
|
11
|
-
}, []);
|
|
12
|
-
}
|
|
13
|
-
function ExtractTypeLeft(left, right) {
|
|
5
|
+
import { EvaluateType } from '../evaluate/evaluate.mjs';
|
|
6
|
+
import { EvaluateUnion } from '../evaluate/evaluate.mjs';
|
|
7
|
+
function ExtractType(left, right) {
|
|
14
8
|
const check = Extends({}, left, right);
|
|
15
9
|
const result = ExtendsResult.IsExtendsTrueLike(check) ? [left] : [];
|
|
16
10
|
return result;
|
|
17
11
|
}
|
|
12
|
+
function ExtractUnion(types, right) {
|
|
13
|
+
return types.reduce((result, head) => {
|
|
14
|
+
return [...result, ...ExtractType(head, right)];
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
18
17
|
export function ExtractOperation(left, right) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const evaluated = EvaluateType(left);
|
|
19
|
+
const canonical = IsUnion(evaluated) ? evaluated.anyOf : [evaluated];
|
|
20
|
+
const remaining = ExtractUnion(canonical, right);
|
|
22
21
|
const result = EvaluateUnion(remaining);
|
|
23
22
|
return result;
|
|
24
23
|
}
|
|
@@ -18,7 +18,6 @@ export * from './module/index.mjs';
|
|
|
18
18
|
export * from './non_nullable/index.mjs';
|
|
19
19
|
export * from './object/index.mjs';
|
|
20
20
|
export * from './omit/index.mjs';
|
|
21
|
-
export * from './options/index.mjs';
|
|
22
21
|
export * from './parameters/index.mjs';
|
|
23
22
|
export * from './patterns/index.mjs';
|
|
24
23
|
export * from './partial/index.mjs';
|
|
@@ -29,3 +28,4 @@ export * from './ref/index.mjs';
|
|
|
29
28
|
export * from './required/index.mjs';
|
|
30
29
|
export * from './return_type/index.mjs';
|
|
31
30
|
export * from './template_literal/index.mjs';
|
|
31
|
+
export * from './with/index.mjs';
|
|
@@ -24,7 +24,6 @@ export * from './module/index.mjs';
|
|
|
24
24
|
export * from './non_nullable/index.mjs';
|
|
25
25
|
export * from './object/index.mjs';
|
|
26
26
|
export * from './omit/index.mjs';
|
|
27
|
-
export * from './options/index.mjs';
|
|
28
27
|
export * from './parameters/index.mjs';
|
|
29
28
|
export * from './patterns/index.mjs';
|
|
30
29
|
export * from './partial/index.mjs';
|
|
@@ -35,3 +34,4 @@ export * from './ref/index.mjs';
|
|
|
35
34
|
export * from './required/index.mjs';
|
|
36
35
|
export * from './return_type/index.mjs';
|
|
37
36
|
export * from './template_literal/index.mjs';
|
|
37
|
+
export * from './with/index.mjs';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
+
import { type TFromType } from './from_type.mjs';
|
|
3
|
+
import { type TEvaluateDependent } from '../evaluate/evaluate.mjs';
|
|
4
|
+
export type TFromDependent<If extends TSchema, Then extends TSchema, Else extends TSchema, Evaluated extends TSchema = TEvaluateDependent<If, Then, Else>, Result extends string[] = TFromType<Evaluated>> = Result;
|
|
5
|
+
export declare function FromDependent<If extends TSchema, Then extends TSchema, Else extends TSchema>(if_: If, then_: Then, else_: Else): TFromDependent<If, Then, Else>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { FromType } from './from_type.mjs';
|
|
3
|
+
import { EvaluateDependent } from '../evaluate/evaluate.mjs';
|
|
4
|
+
export function FromDependent(if_, then_, else_) {
|
|
5
|
+
const evaluated = EvaluateDependent(if_, then_, else_);
|
|
6
|
+
const result = FromType(evaluated);
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TEnumValue } from '../../types/enum.mjs';
|
|
3
|
-
import { type
|
|
4
|
-
import { type
|
|
5
|
-
export type TFromEnum<Values extends TEnumValue[],
|
|
3
|
+
import { type TFromType } from './from_type.mjs';
|
|
4
|
+
import { type TEvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
5
|
+
export type TFromEnum<Values extends TEnumValue[], Evaluated extends TSchema = TEvaluateEnum<Values>, Result extends string[] = TFromType<Evaluated>> = Result;
|
|
6
6
|
export declare function FromEnum<Values extends TEnumValue[]>(values: [...Values]): TFromEnum<Values>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FromType } from './from_type.mjs';
|
|
3
|
+
import { EvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
4
4
|
export function FromEnum(values) {
|
|
5
|
-
const
|
|
6
|
-
const result =
|
|
5
|
+
const evaluated = EvaluateEnum(values);
|
|
6
|
+
const result = FromType(evaluated);
|
|
7
7
|
return result;
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
|
-
import { type TTemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
3
2
|
import { type TFromType } from './from_type.mjs';
|
|
4
|
-
|
|
3
|
+
import { type TEvaluateTemplateLiteral } from '../evaluate/evaluate.mjs';
|
|
4
|
+
export type TFromTemplateLiteral<Pattern extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>, Result extends string[] = TFromType<Evaluated>> = Result;
|
|
5
5
|
export declare function FromTemplateLiteral<Pattern extends string>(pattern: Pattern): TFromTemplateLiteral<Pattern>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { TemplateLiteralDecode } from '../template_literal/decode.mjs';
|
|
3
2
|
import { FromType } from './from_type.mjs';
|
|
3
|
+
import { EvaluateTemplateLiteral } from '../evaluate/evaluate.mjs';
|
|
4
4
|
export function FromTemplateLiteral(pattern) {
|
|
5
|
-
const
|
|
6
|
-
const result = FromType(
|
|
5
|
+
const evaluated = EvaluateTemplateLiteral(pattern);
|
|
6
|
+
const result = FromType(evaluated);
|
|
7
7
|
return result;
|
|
8
8
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TSchema } from '../../types/schema.mjs';
|
|
2
2
|
import { type TCyclic } from '../../types/cyclic.mjs';
|
|
3
|
+
import { type TDependent } from '../../types/dependent.mjs';
|
|
3
4
|
import { type TEnum, type TEnumValue } from '../../types/enum.mjs';
|
|
4
5
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
5
6
|
import { type TLiteral, type TLiteralValue } from '../../types/literal.mjs';
|
|
@@ -7,11 +8,12 @@ import { type TProperties } from '../../types/properties.mjs';
|
|
|
7
8
|
import { type TTemplateLiteral } from '../../types/template_literal.mjs';
|
|
8
9
|
import { type TUnion } from '../../types/union.mjs';
|
|
9
10
|
import { type TFromCyclic } from './from_cyclic.mjs';
|
|
11
|
+
import { type TFromDependent } from './from_dependent.mjs';
|
|
10
12
|
import { type TFromEnum } from './from_enum.mjs';
|
|
11
13
|
import { type TFromIntersect } from './from_intersect.mjs';
|
|
12
14
|
import { type TFromLiteral } from './from_literal.mjs';
|
|
13
15
|
import { type TFromTemplateLiteral } from './from_template_literal.mjs';
|
|
14
16
|
import { type TFromUnion } from './from_union.mjs';
|
|
15
|
-
export type TFromType<Indexer extends TSchema, Result extends string[] = (Indexer extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic<Defs, Ref> : Indexer extends TEnum<infer Values extends TEnumValue[]> ? TFromEnum<Values> : Indexer extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<Types> : Indexer extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral<Value> : Indexer extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateLiteral<Pattern> : Indexer extends TUnion<infer Types extends TSchema[]> ? TFromUnion<Types> : [
|
|
17
|
+
export type TFromType<Indexer extends TSchema, Result extends string[] = (Indexer extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? TFromCyclic<Defs, Ref> : Indexer extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TFromDependent<If, Then, Else> : Indexer extends TEnum<infer Values extends TEnumValue[]> ? TFromEnum<Values> : Indexer extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<Types> : Indexer extends TLiteral<infer Value extends TLiteralValue> ? TFromLiteral<Value> : Indexer extends TTemplateLiteral<infer Pattern extends string> ? TFromTemplateLiteral<Pattern> : Indexer extends TUnion<infer Types extends TSchema[]> ? TFromUnion<Types> : [
|
|
16
18
|
])> = Result;
|
|
17
19
|
export declare function FromType<Indexer extends TSchema>(type: Indexer): TFromType<Indexer>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { IsCyclic } from '../../types/cyclic.mjs';
|
|
3
|
+
import { IsDependent } from '../../types/dependent.mjs';
|
|
3
4
|
import { IsEnum } from '../../types/enum.mjs';
|
|
4
5
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
5
6
|
import { IsLiteral } from '../../types/literal.mjs';
|
|
6
7
|
import { IsTemplateLiteral } from '../../types/template_literal.mjs';
|
|
7
8
|
import { IsUnion } from '../../types/union.mjs';
|
|
8
9
|
import { FromCyclic } from './from_cyclic.mjs';
|
|
10
|
+
import { FromDependent } from './from_dependent.mjs';
|
|
9
11
|
import { FromEnum } from './from_enum.mjs';
|
|
10
12
|
import { FromIntersect } from './from_intersect.mjs';
|
|
11
13
|
import { FromLiteral } from './from_literal.mjs';
|
|
@@ -13,10 +15,11 @@ import { FromTemplateLiteral } from './from_template_literal.mjs';
|
|
|
13
15
|
import { FromUnion } from './from_union.mjs';
|
|
14
16
|
export function FromType(type) {
|
|
15
17
|
return (IsCyclic(type) ? FromCyclic(type.$defs, type.$ref) :
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
IsDependent(type) ? FromDependent(type.if, type.then, type.else) :
|
|
19
|
+
IsEnum(type) ? FromEnum(type.enum) :
|
|
20
|
+
IsIntersect(type) ? FromIntersect(type.allOf) :
|
|
21
|
+
IsLiteral(type) ? FromLiteral(type.const) :
|
|
22
|
+
IsTemplateLiteral(type) ? FromTemplateLiteral(type.pattern) :
|
|
23
|
+
IsUnion(type) ? FromUnion(type.anyOf) :
|
|
24
|
+
[]);
|
|
22
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TSchema, type TSchemaOptions } from '../../types/schema.mjs';
|
|
2
2
|
import { type TCyclic } from '../../types/cyclic.mjs';
|
|
3
|
+
import { type TDependent } from '../../types/dependent.mjs';
|
|
3
4
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
4
5
|
import { type TProperties } from '../../types/properties.mjs';
|
|
5
6
|
import { type TUnion } from '../../types/union.mjs';
|
|
@@ -7,7 +8,7 @@ import { type TState, type TInstantiateType, type TCanInstantiate } from '../ins
|
|
|
7
8
|
import { type TIndexDeferred } from '../../action/indexed.mjs';
|
|
8
9
|
import { type TCollapseToObject } from '../object/index.mjs';
|
|
9
10
|
import { type TFromType } from './from_type.mjs';
|
|
10
|
-
type TNormalizeType<Type extends TSchema, Result extends TSchema = (Type extends TCyclic | TIntersect | TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
11
|
+
type TNormalizeType<Type extends TSchema, Result extends TSchema = (Type extends TCyclic | TDependent | TIntersect | TUnion ? TCollapseToObject<Type> : Type)> = Result;
|
|
11
12
|
export type TIndexAction<Type extends TSchema, Indexer extends TSchema, Result extends TSchema = TCanInstantiate<[Type, Indexer]> extends true ? TFromType<TNormalizeType<Type>, Indexer> : TIndexDeferred<Type, Indexer>> = Result;
|
|
12
13
|
export declare function IndexAction<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer, options: TSchemaOptions): TIndexAction<Type, Indexer>;
|
|
13
14
|
export type TIndexInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TIndexAction<InstantiatedType, InstantiatedIndexer>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { IsCyclic } from '../../types/cyclic.mjs';
|
|
4
|
+
import { IsDependent } from '../../types/dependent.mjs';
|
|
4
5
|
import { IsIntersect } from '../../types/intersect.mjs';
|
|
5
6
|
import { IsUnion } from '../../types/union.mjs';
|
|
6
7
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
@@ -8,7 +9,7 @@ import { IndexDeferred } from '../../action/indexed.mjs';
|
|
|
8
9
|
import { CollapseToObject } from '../object/index.mjs';
|
|
9
10
|
import { FromType } from './from_type.mjs';
|
|
10
11
|
function NormalizeType(type) {
|
|
11
|
-
const result = (IsCyclic(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) :
|
|
12
|
+
const result = (IsCyclic(type) || IsDependent(type) || IsIntersect(type) || IsUnion(type) ? CollapseToObject(type) :
|
|
12
13
|
type);
|
|
13
14
|
return result;
|
|
14
15
|
}
|
|
@@ -9,6 +9,7 @@ import { type TDeferred } from '../types/deferred.mjs';
|
|
|
9
9
|
import { type TFunction } from '../types/function.mjs';
|
|
10
10
|
import { type TCall } from '../types/call.mjs';
|
|
11
11
|
import { type TIdentifier } from '../types/identifier.mjs';
|
|
12
|
+
import { type TDependent } from '../types/dependent.mjs';
|
|
12
13
|
import { type TIntersect } from '../types/intersect.mjs';
|
|
13
14
|
import { type TIterator } from '../types/iterator.mjs';
|
|
14
15
|
import { type TObject } from '../types/object.mjs';
|
|
@@ -38,7 +39,6 @@ import { type TMappedInstantiate } from './mapped/instantiate.mjs';
|
|
|
38
39
|
import { type TModuleInstantiate } from './module/instantiate.mjs';
|
|
39
40
|
import { type TNonNullableInstantiate } from './non_nullable/instantiate.mjs';
|
|
40
41
|
import { type TOmitInstantiate } from './omit/instantiate.mjs';
|
|
41
|
-
import { type TOptionsInstantiate } from './options/instantiate.mjs';
|
|
42
42
|
import { type TParametersInstantiate } from './parameters/instantiate.mjs';
|
|
43
43
|
import { type TPartialInstantiate } from './partial/instantiate.mjs';
|
|
44
44
|
import { type TPickInstantiate } from './pick/instantiate.mjs';
|
|
@@ -50,6 +50,7 @@ import { type TReturnTypeInstantiate } from './return_type/instantiate.mjs';
|
|
|
50
50
|
import { type TTemplateLiteralInstantiate } from './template_literal/instantiate.mjs';
|
|
51
51
|
import { type TUncapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
52
52
|
import { type TUppercaseInstantiate } from './intrinsics/instantiate.mjs';
|
|
53
|
+
import { type TWithInstantiate } from './with/instantiate.mjs';
|
|
53
54
|
import { type TRestSpread } from './rest/index.mjs';
|
|
54
55
|
export interface TState {
|
|
55
56
|
callstack: string[];
|
|
@@ -123,9 +124,6 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
123
124
|
] extends ['Pick', [infer Type extends TSchema, infer Indexer extends TSchema]] ? TPickInstantiate<Context, State, Type, Indexer> : [
|
|
124
125
|
Action,
|
|
125
126
|
Parameters
|
|
126
|
-
] extends ['Options', [infer Type extends TSchema, infer Options extends TSchema]] ? TOptionsInstantiate<Context, State, Type, Options> : [
|
|
127
|
-
Action,
|
|
128
|
-
Parameters
|
|
129
127
|
] extends ['Parameters', [infer Type extends TSchema]] ? TParametersInstantiate<Context, State, Type> : [
|
|
130
128
|
Action,
|
|
131
129
|
Parameters
|
|
@@ -153,8 +151,11 @@ type TInstantiateDeferred<Context extends TProperties, State extends TState, Act
|
|
|
153
151
|
] extends ['Uncapitalize', [infer Type extends TSchema]] ? TUncapitalizeInstantiate<Context, State, Type> : [
|
|
154
152
|
Action,
|
|
155
153
|
Parameters
|
|
156
|
-
] extends ['Uppercase', [infer Type extends TSchema]] ? TUppercaseInstantiate<Context, State, Type> :
|
|
157
|
-
|
|
154
|
+
] extends ['Uppercase', [infer Type extends TSchema]] ? TUppercaseInstantiate<Context, State, Type> : [
|
|
155
|
+
Action,
|
|
156
|
+
Parameters
|
|
157
|
+
] extends ['With', [infer Type extends TSchema, infer Options extends TSchema]] ? TWithInstantiate<Context, State, Type, Options> : TDeferred<Action, Parameters>);
|
|
158
|
+
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;
|
|
158
159
|
export declare function InstantiateType<Context extends TProperties, State extends TState, Type extends TSchema>(context: Context, state: State, input: Type): TInstantiateType<Context, State, Type>;
|
|
159
160
|
/** Instantiates computed schematics using the given context and type. */
|
|
160
161
|
export type TInstantiate<Context extends TProperties, Type extends TSchema> = (TInstantiateType<Context, {
|