typebox 1.2.19 → 1.3.1
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/compile/validator.d.mts +2 -7
- package/build/compile/validator.mjs +6 -36
- package/build/error/errors.d.mts +1 -7
- package/build/format/_idna.mjs +11 -3
- package/build/guard/emit.d.mts +0 -4
- package/build/guard/emit.mjs +0 -8
- package/build/guard/guard.d.mts +0 -4
- package/build/guard/guard.mjs +0 -8
- package/build/schema/engine/index.d.mts +0 -1
- package/build/schema/engine/index.mjs +0 -1
- package/build/schema/engine/schema.mjs +0 -5
- package/build/schema/engine/type.mjs +14 -18
- package/build/schema/types/index.d.mts +0 -1
- package/build/schema/types/index.mjs +0 -1
- package/build/system/locale/ar_001.mjs +0 -1
- package/build/system/locale/bn_BD.mjs +0 -1
- package/build/system/locale/cs_CZ.mjs +0 -1
- package/build/system/locale/de_DE.mjs +0 -1
- package/build/system/locale/el_GR.mjs +0 -1
- package/build/system/locale/en_US.mjs +0 -1
- package/build/system/locale/es_419.mjs +0 -1
- package/build/system/locale/es_AR.mjs +0 -1
- package/build/system/locale/es_ES.mjs +0 -1
- package/build/system/locale/es_MX.mjs +0 -1
- package/build/system/locale/fa_IR.mjs +0 -1
- package/build/system/locale/fil_PH.mjs +0 -1
- package/build/system/locale/fr_CA.mjs +0 -1
- package/build/system/locale/fr_FR.mjs +0 -1
- package/build/system/locale/ha_NG.mjs +0 -1
- package/build/system/locale/hi_IN.mjs +0 -1
- package/build/system/locale/hu_HU.mjs +0 -1
- package/build/system/locale/id_ID.mjs +0 -1
- package/build/system/locale/it_IT.mjs +0 -1
- package/build/system/locale/ja_JP.mjs +0 -1
- package/build/system/locale/ko_KR.mjs +0 -1
- package/build/system/locale/ms_MY.mjs +0 -1
- package/build/system/locale/nl_NL.mjs +0 -1
- package/build/system/locale/pl_PL.mjs +0 -1
- package/build/system/locale/pt_BR.mjs +0 -1
- package/build/system/locale/pt_PT.mjs +0 -1
- package/build/system/locale/ro_RO.mjs +0 -1
- package/build/system/locale/ru_RU.mjs +0 -1
- package/build/system/locale/sv_SE.mjs +0 -1
- package/build/system/locale/sw_TZ.mjs +0 -1
- package/build/system/locale/th_TH.mjs +0 -1
- package/build/system/locale/tr_TR.mjs +0 -1
- package/build/system/locale/uk_UA.mjs +0 -1
- package/build/system/locale/ur_PK.mjs +0 -1
- package/build/system/locale/vi_VN.mjs +0 -1
- package/build/system/locale/yo_NG.mjs +0 -1
- package/build/system/locale/zh_Hans.mjs +0 -1
- package/build/system/locale/zh_Hant.mjs +0 -1
- package/build/system/memory/clone.d.mts +2 -3
- package/build/system/memory/clone.mjs +73 -26
- package/build/type/action/index.d.mts +0 -1
- package/build/type/action/index.mjs +0 -1
- package/build/type/action/readonly_object.d.mts +0 -5
- package/build/type/action/readonly_object.mjs +0 -5
- package/build/type/action/with.d.mts +0 -10
- package/build/type/action/with.mjs +0 -8
- package/build/type/engine/cyclic/check.d.mts +1 -4
- package/build/type/engine/cyclic/check.mjs +9 -15
- package/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/build/type/engine/cyclic/extends.d.mts +1 -4
- package/build/type/engine/cyclic/extends.mjs +8 -14
- package/build/type/engine/index.d.mts +0 -1
- package/build/type/engine/index.mjs +0 -1
- package/build/type/engine/instantiate.d.mts +1 -8
- package/build/type/engine/instantiate.mjs +38 -46
- package/build/type/engine/this/expand_this.d.mts +1 -4
- package/build/type/engine/this/expand_this.mjs +7 -13
- package/build/type/extends/extends_left.d.mts +1 -7
- package/build/type/extends/extends_left.mjs +23 -32
- package/build/type/script/mapping.d.mts +0 -12
- package/build/type/script/mapping.mjs +21 -25
- package/build/type/types/_refine.d.mts +0 -2
- package/build/type/types/_refine.mjs +1 -2
- package/build/type/types/index.d.mts +0 -4
- package/build/type/types/index.mjs +0 -4
- package/build/type/types/static.d.mts +1 -5
- package/build/typebox.d.mts +2 -7
- package/build/typebox.mjs +2 -7
- package/build/value/clean/from_type.mjs +8 -10
- package/build/value/clone/clone.mjs +1 -86
- package/build/value/convert/from_type.mjs +19 -21
- package/build/value/create/from_type.mjs +23 -31
- package/build/value/default/from_type.mjs +8 -10
- package/build/value/index.d.mts +0 -1
- package/build/value/index.mjs +0 -1
- package/build/value/repair/from_type.mjs +2 -12
- package/build/value/value.d.mts +0 -1
- package/build/value/value.mjs +0 -1
- package/package.json +1 -1
- package/readme.md +8 -5
- package/build/schema/engine/_guard.d.mts +0 -6
- package/build/schema/engine/_guard.mjs +0 -26
- package/build/schema/types/_guard.d.mts +0 -10
- package/build/schema/types/_guard.mjs +0 -16
- package/build/type/action/awaited.d.mts +0 -15
- package/build/type/action/awaited.mjs +0 -15
- package/build/type/engine/awaited/index.d.mts +0 -1
- package/build/type/engine/awaited/index.mjs +0 -1
- package/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/build/type/engine/awaited/instantiate.mjs +0 -20
- package/build/type/extends/async_iterator.d.mts +0 -7
- package/build/type/extends/async_iterator.mjs +0 -9
- package/build/type/extends/iterator.d.mts +0 -7
- package/build/type/extends/iterator.mjs +0 -9
- package/build/type/extends/promise.d.mts +0 -7
- package/build/type/extends/promise.mjs +0 -9
- package/build/type/types/async_iterator.d.mts +0 -20
- package/build/type/types/async_iterator.mjs +0 -28
- package/build/type/types/base.d.mts +0 -50
- package/build/type/types/base.mjs +0 -84
- package/build/type/types/iterator.d.mts +0 -20
- package/build/type/types/iterator.mjs +0 -28
- package/build/type/types/promise.d.mts +0 -21
- package/build/type/types/promise.mjs +0 -29
- package/build/value/clean/from_base.d.mts +0 -2
- package/build/value/clean/from_base.mjs +0 -4
- package/build/value/convert/from_base.d.mts +0 -2
- package/build/value/convert/from_base.mjs +0 -4
- package/build/value/create/from_async_iterator.d.mts +0 -2
- package/build/value/create/from_async_iterator.mjs +0 -5
- package/build/value/create/from_base.d.mts +0 -2
- package/build/value/create/from_base.mjs +0 -4
- package/build/value/create/from_iterator.d.mts +0 -2
- package/build/value/create/from_iterator.mjs +0 -5
- package/build/value/create/from_promise.d.mts +0 -2
- package/build/value/create/from_promise.mjs +0 -5
- package/build/value/default/from_base.d.mts +0 -2
- package/build/value/default/from_base.mjs +0 -5
- package/build/value/mutate/error.d.mts +0 -3
- package/build/value/mutate/error.mjs +0 -6
- package/build/value/mutate/from_array.d.mts +0 -2
- package/build/value/mutate/from_array.mjs +0 -16
- package/build/value/mutate/from_object.d.mts +0 -2
- package/build/value/mutate/from_object.mjs +0 -40
- package/build/value/mutate/from_unknown.d.mts +0 -2
- package/build/value/mutate/from_unknown.mjs +0 -7
- package/build/value/mutate/from_value.d.mts +0 -2
- package/build/value/mutate/from_value.mjs +0 -12
- package/build/value/mutate/index.d.mts +0 -1
- package/build/value/mutate/index.mjs +0 -1
- package/build/value/mutate/mutate.d.mts +0 -11
- package/build/value/mutate/mutate.mjs +0 -41
- package/build/value/repair/from_base.d.mts +0 -2
- package/build/value/repair/from_base.mjs +0 -8
|
@@ -8,16 +8,13 @@ import { AddImmutableAction } from './immutable/instantiate_add.mjs';
|
|
|
8
8
|
import { AddReadonlyAction } from './readonly/instantiate_add.mjs';
|
|
9
9
|
import { AddOptionalAction } from './optional/instantiate_add.mjs';
|
|
10
10
|
import { _Array_, IsArray, ArrayOptions } from '../types/array.mjs';
|
|
11
|
-
import { AsyncIterator, IsAsyncIterator, AsyncIteratorOptions } from '../types/async_iterator.mjs';
|
|
12
11
|
import { Constructor, IsConstructor, ConstructorOptions } from '../types/constructor.mjs';
|
|
13
12
|
import { Deferred, IsDeferred } from '../types/deferred.mjs';
|
|
14
13
|
import { _Function_, IsFunction, FunctionOptions } from '../types/function.mjs';
|
|
15
14
|
import { IsCall } from '../types/call.mjs';
|
|
16
15
|
import { Dependent, IsDependent, DependentOptions } from '../types/dependent.mjs';
|
|
17
16
|
import { Intersect, IsIntersect, IntersectOptions } from '../types/intersect.mjs';
|
|
18
|
-
import { Iterator, IsIterator, IteratorOptions } from '../types/iterator.mjs';
|
|
19
17
|
import { Object, IsObject, ObjectOptions } from '../types/object.mjs';
|
|
20
|
-
import { _Promise_, IsPromise, PromiseOptions } from '../types/promise.mjs';
|
|
21
18
|
import { RecordFromPattern, IsRecord, RecordPattern, RecordValue } from '../types/record.mjs';
|
|
22
19
|
import { Tuple, IsTuple, TupleOptions } from '../types/tuple.mjs';
|
|
23
20
|
import { Union, IsUnion, UnionOptions } from '../types/union.mjs';
|
|
@@ -38,7 +35,6 @@ import { IsReadonly } from '../types/_readonly.mjs';
|
|
|
38
35
|
// ------------------------------------------------------------------
|
|
39
36
|
// Instantiate
|
|
40
37
|
// ------------------------------------------------------------------
|
|
41
|
-
import { AwaitedInstantiate } from './awaited/instantiate.mjs';
|
|
42
38
|
import { CallInstantiate } from './call/instantiate.mjs';
|
|
43
39
|
import { CapitalizeInstantiate } from './intrinsics/instantiate.mjs';
|
|
44
40
|
import { ConditionalInstantiate } from './conditional/index.mjs';
|
|
@@ -105,52 +101,48 @@ function InstantiateDeferred(context, state, action, parameters, options) {
|
|
|
105
101
|
Guard.IsEqual(action, 'AddOptional') ? AddOptionalInstantiate(context, state, parameters[0], options) :
|
|
106
102
|
Guard.IsEqual(action, 'RemoveOptional') ? RemoveOptionalInstantiate(context, state, parameters[0], options) :
|
|
107
103
|
// Actions
|
|
108
|
-
Guard.IsEqual(action, '
|
|
109
|
-
Guard.IsEqual(action, '
|
|
110
|
-
Guard.IsEqual(action, '
|
|
111
|
-
Guard.IsEqual(action, '
|
|
112
|
-
Guard.IsEqual(action, '
|
|
113
|
-
Guard.IsEqual(action, '
|
|
114
|
-
Guard.IsEqual(action, '
|
|
115
|
-
Guard.IsEqual(action, '
|
|
116
|
-
Guard.IsEqual(action, '
|
|
117
|
-
Guard.IsEqual(action, '
|
|
118
|
-
Guard.IsEqual(action, '
|
|
119
|
-
Guard.IsEqual(action, '
|
|
120
|
-
Guard.IsEqual(action, '
|
|
121
|
-
Guard.IsEqual(action, '
|
|
122
|
-
Guard.IsEqual(action, '
|
|
123
|
-
Guard.IsEqual(action, '
|
|
124
|
-
Guard.IsEqual(action, '
|
|
125
|
-
Guard.IsEqual(action, '
|
|
126
|
-
Guard.IsEqual(action, '
|
|
127
|
-
Guard.IsEqual(action, '
|
|
128
|
-
Guard.IsEqual(action, '
|
|
129
|
-
Guard.IsEqual(action, '
|
|
130
|
-
Guard.IsEqual(action, '
|
|
131
|
-
Guard.IsEqual(action, '
|
|
132
|
-
Guard.IsEqual(action, '
|
|
133
|
-
Guard.IsEqual(action, '
|
|
134
|
-
|
|
135
|
-
Deferred(action, parameters, options));
|
|
104
|
+
Guard.IsEqual(action, 'Capitalize') ? CapitalizeInstantiate(context, state, parameters[0], options) :
|
|
105
|
+
Guard.IsEqual(action, 'Conditional') ? ConditionalInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) :
|
|
106
|
+
Guard.IsEqual(action, 'ConstructorParameters') ? ConstructorParametersInstantiate(context, state, parameters[0], options) :
|
|
107
|
+
Guard.IsEqual(action, 'Evaluate') ? EvaluateInstantiate(context, state, parameters[0], options) :
|
|
108
|
+
Guard.IsEqual(action, 'Exclude') ? ExcludeInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
109
|
+
Guard.IsEqual(action, 'Extract') ? ExtractInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
110
|
+
Guard.IsEqual(action, 'Index') ? IndexInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
111
|
+
Guard.IsEqual(action, 'InstanceType') ? InstanceTypeInstantiate(context, state, parameters[0], options) :
|
|
112
|
+
Guard.IsEqual(action, 'Interface') ? InterfaceInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
113
|
+
Guard.IsEqual(action, 'KeyOf') ? KeyOfInstantiate(context, state, parameters[0], options) :
|
|
114
|
+
Guard.IsEqual(action, 'Lowercase') ? LowercaseInstantiate(context, state, parameters[0], options) :
|
|
115
|
+
Guard.IsEqual(action, 'Mapped') ? MappedInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) :
|
|
116
|
+
Guard.IsEqual(action, 'Module') ? ModuleInstantiate(context, state, parameters[0], options) :
|
|
117
|
+
Guard.IsEqual(action, 'NonNullable') ? NonNullableInstantiate(context, state, parameters[0], options) :
|
|
118
|
+
Guard.IsEqual(action, 'Pick') ? PickInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
119
|
+
Guard.IsEqual(action, 'Parameters') ? ParametersInstantiate(context, state, parameters[0], options) :
|
|
120
|
+
Guard.IsEqual(action, 'Partial') ? PartialInstantiate(context, state, parameters[0], options) :
|
|
121
|
+
Guard.IsEqual(action, 'Omit') ? OmitInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
122
|
+
Guard.IsEqual(action, 'ReadonlyObject') ? ReadonlyObjectInstantiate(context, state, parameters[0], options) :
|
|
123
|
+
Guard.IsEqual(action, 'Record') ? RecordInstantiate(context, state, parameters[0], parameters[1], options) :
|
|
124
|
+
Guard.IsEqual(action, 'Required') ? RequiredInstantiate(context, state, parameters[0], options) :
|
|
125
|
+
Guard.IsEqual(action, 'ReturnType') ? ReturnTypeInstantiate(context, state, parameters[0], options) :
|
|
126
|
+
Guard.IsEqual(action, 'TemplateLiteral') ? TemplateLiteralInstantiate(context, state, parameters[0], options) :
|
|
127
|
+
Guard.IsEqual(action, 'Uncapitalize') ? UncapitalizeInstantiate(context, state, parameters[0], options) :
|
|
128
|
+
Guard.IsEqual(action, 'Uppercase') ? UppercaseInstantiate(context, state, parameters[0], options) :
|
|
129
|
+
Guard.IsEqual(action, 'With') ? WithInstantiate(context, state, parameters[0], parameters[1]) :
|
|
130
|
+
Deferred(action, parameters, options));
|
|
136
131
|
}
|
|
137
132
|
function InstantiateImmediate(context, state, type) {
|
|
138
133
|
const instantiatedType = (IsRef(type) ? RefInstantiate(context, state, type, type.$ref) :
|
|
139
134
|
IsArray(type) ? _Array_(InstantiateType(context, state, type.items), ArrayOptions(type)) :
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) :
|
|
152
|
-
IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) :
|
|
153
|
-
type);
|
|
135
|
+
IsCall(type) ? CallInstantiate(context, state, type.target, type.arguments) :
|
|
136
|
+
IsConstructor(type) ? Constructor(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.instanceType), ConstructorOptions(type)) :
|
|
137
|
+
IsFunction(type) ? _Function_(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.returnType), FunctionOptions(type)) :
|
|
138
|
+
IsDependent(type) ? Dependent(InstantiateType(context, state, type.if), InstantiateType(context, state, type.then), InstantiateType(context, state, type.else), DependentOptions(type)) :
|
|
139
|
+
IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) :
|
|
140
|
+
IsObject(type) ? Object(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) :
|
|
141
|
+
IsRecord(type) ? RecordFromPattern(RecordPattern(type), InstantiateType(context, state, RecordValue(type))) :
|
|
142
|
+
IsRest(type) ? Rest(InstantiateType(context, state, type.items)) :
|
|
143
|
+
IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) :
|
|
144
|
+
IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) :
|
|
145
|
+
type);
|
|
154
146
|
const withModifiers = WithModifiers(type, instantiatedType);
|
|
155
147
|
return withModifiers;
|
|
156
148
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { type TArray } from '../../types/array.mjs';
|
|
2
|
-
import { type TAsyncIterator } from '../../types/async_iterator.mjs';
|
|
3
2
|
import { type TConstructor } from '../../types/constructor.mjs';
|
|
4
3
|
import { type TFunction } from '../../types/function.mjs';
|
|
5
|
-
import { type TIterator } from '../../types/iterator.mjs';
|
|
6
4
|
import { type TIntersect } from '../../types/intersect.mjs';
|
|
7
5
|
import { type TObject } from '../../types/object.mjs';
|
|
8
6
|
import { type TProperties } from '../../types/properties.mjs';
|
|
9
7
|
import { type TSchema } from '../../types/schema.mjs';
|
|
10
|
-
import { type TPromise } from '../../types/promise.mjs';
|
|
11
8
|
import { type TTuple } from '../../types/tuple.mjs';
|
|
12
9
|
import { type TThis } from '../../types/this.mjs';
|
|
13
10
|
import { type TUnion } from '../../types/union.mjs';
|
|
14
11
|
type TFromTypes<Properties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes<Properties, Right, [...Result, TFromType<Properties, Left>]> : Result);
|
|
15
|
-
export type TFromType<Properties extends TProperties, Type extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TArray<TFromType<Properties, Type>> : Type extends
|
|
12
|
+
export type TFromType<Properties extends TProperties, Type extends TSchema> = (Type extends TArray<infer Type extends TSchema> ? TArray<TFromType<Properties, Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TFromTypes<Properties, Parameters>, TFromType<Properties, InstanceType>> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TFromTypes<Properties, Parameters>, TFromType<Properties, ReturnType>> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TFromTypes<Properties, Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromTypes<Properties, Types>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromTypes<Properties, Types>> : Type extends TThis ? TObject<Properties> : Type);
|
|
16
13
|
export declare function FromType<Properties extends TProperties, Type extends TSchema>(properties: Properties, type: Type): TFromType<Properties, Type>;
|
|
17
14
|
export type TExpandThis<Properties extends TProperties, Type extends TSchema, Result extends TSchema = TFromType<Properties, Type>> = Result;
|
|
18
15
|
export declare function ExpandThis<Properties extends TProperties, Type extends TSchema>(properties: TProperties, type: Type): TExpandThis<Properties, Type>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { IsArray, _Array_ } from '../../types/array.mjs';
|
|
3
|
-
import { IsAsyncIterator, AsyncIterator } from '../../types/async_iterator.mjs';
|
|
4
3
|
import { IsConstructor, Constructor } from '../../types/constructor.mjs';
|
|
5
4
|
import { IsFunction, _Function_ } from '../../types/function.mjs';
|
|
6
|
-
import { IsIterator, Iterator } from '../../types/iterator.mjs';
|
|
7
5
|
import { IsIntersect, Intersect } from '../../types/intersect.mjs';
|
|
8
6
|
import { _Object_ } from '../../types/object.mjs';
|
|
9
|
-
import { IsPromise, Promise } from '../../types/promise.mjs';
|
|
10
7
|
import { IsTuple, Tuple } from '../../types/tuple.mjs';
|
|
11
8
|
import { IsThis } from '../../types/this.mjs';
|
|
12
9
|
import { IsUnion, Union } from '../../types/union.mjs';
|
|
@@ -15,16 +12,13 @@ function FromTypes(properties, types) {
|
|
|
15
12
|
}
|
|
16
13
|
export function FromType(properties, type) {
|
|
17
14
|
return (IsArray(type) ? _Array_(FromType(properties, type.items)) :
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
IsIntersect(type) ? Intersect(FromTypes(properties, type.allOf)) :
|
|
26
|
-
IsThis(type) ? _Object_(properties) :
|
|
27
|
-
type);
|
|
15
|
+
IsConstructor(type) ? Constructor(FromTypes(properties, type.parameters), FromType(properties, type.instanceType)) :
|
|
16
|
+
IsFunction(type) ? _Function_(FromTypes(properties, type.parameters), FromType(properties, type.returnType)) :
|
|
17
|
+
IsTuple(type) ? Tuple(FromTypes(properties, type.items)) :
|
|
18
|
+
IsUnion(type) ? Union(FromTypes(properties, type.anyOf)) :
|
|
19
|
+
IsIntersect(type) ? Intersect(FromTypes(properties, type.allOf)) :
|
|
20
|
+
IsThis(type) ? _Object_(properties) :
|
|
21
|
+
type);
|
|
28
22
|
}
|
|
29
23
|
export function ExpandThis(properties, type) {
|
|
30
24
|
const result = FromType(properties, type);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type TExtendsAny } from './any.mjs';
|
|
2
2
|
import { type TExtendsArray } from './array.mjs';
|
|
3
|
-
import { type TExtendsAsyncIterator } from './async_iterator.mjs';
|
|
4
3
|
import { type TExtendsBigInt } from './bigint.mjs';
|
|
5
4
|
import { type TExtendsBoolean } from './boolean.mjs';
|
|
6
5
|
import { type TExtendsConstructor } from './constructor.mjs';
|
|
@@ -9,13 +8,11 @@ import { type TExtendsEnum } from './enum.mjs';
|
|
|
9
8
|
import { type TExtendsFunction } from './function.mjs';
|
|
10
9
|
import { type TExtendsInteger } from './integer.mjs';
|
|
11
10
|
import { type TExtendsIntersect } from './intersect.mjs';
|
|
12
|
-
import { type TExtendsIterator } from './iterator.mjs';
|
|
13
11
|
import { type TExtendsLiteral } from './literal.mjs';
|
|
14
12
|
import { type TExtendsNever } from './never.mjs';
|
|
15
13
|
import { type TExtendsNull } from './null.mjs';
|
|
16
14
|
import { type TExtendsNumber } from './number.mjs';
|
|
17
15
|
import { type TExtendsObject } from './object.mjs';
|
|
18
|
-
import { type TExtendsPromise } from './promise.mjs';
|
|
19
16
|
import { type TExtendsRecord } from './record.mjs';
|
|
20
17
|
import { type TExtendsString } from './string.mjs';
|
|
21
18
|
import { type TExtendsSymbol } from './symbol.mjs';
|
|
@@ -27,7 +24,6 @@ import { type TExtendsUnknown } from './unknown.mjs';
|
|
|
27
24
|
import { type TExtendsVoid } from './void.mjs';
|
|
28
25
|
import { type TAny } from '../types/any.mjs';
|
|
29
26
|
import { type TArray } from '../types/array.mjs';
|
|
30
|
-
import { type TAsyncIterator } from '../types/async_iterator.mjs';
|
|
31
27
|
import { type TBigInt } from '../types/bigint.mjs';
|
|
32
28
|
import { type TBoolean } from '../types/boolean.mjs';
|
|
33
29
|
import { type TConstructor } from '../types/constructor.mjs';
|
|
@@ -36,13 +32,11 @@ import { type TEnum, type TEnumValue } from '../types/enum.mjs';
|
|
|
36
32
|
import { type TFunction } from '../types/function.mjs';
|
|
37
33
|
import { type TInteger } from '../types/integer.mjs';
|
|
38
34
|
import { type TIntersect } from '../types/intersect.mjs';
|
|
39
|
-
import { type TIterator } from '../types/iterator.mjs';
|
|
40
35
|
import { type TLiteral } from '../types/literal.mjs';
|
|
41
36
|
import { type TNever } from '../types/never.mjs';
|
|
42
37
|
import { type TNull } from '../types/null.mjs';
|
|
43
38
|
import { type TNumber } from '../types/number.mjs';
|
|
44
39
|
import { type TObject } from '../types/object.mjs';
|
|
45
|
-
import { type TPromise } from '../types/promise.mjs';
|
|
46
40
|
import { type TRecord } from '../types/record.mjs';
|
|
47
41
|
import { type TSchema } from '../types/schema.mjs';
|
|
48
42
|
import { type TString } from '../types/string.mjs';
|
|
@@ -55,5 +49,5 @@ import { type TProperties } from '../types/properties.mjs';
|
|
|
55
49
|
import { type TUnion } from '../types/union.mjs';
|
|
56
50
|
import { type TVoid } from '../types/void.mjs';
|
|
57
51
|
import * as Result from './result.mjs';
|
|
58
|
-
export type TExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TAny ? TExtendsAny<Inferred, Left, Right> : Left extends TArray<infer Items extends TSchema> ? TExtendsArray<Inferred, Left, Items, Right> : Left extends
|
|
52
|
+
export type TExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Left extends TAny ? TExtendsAny<Inferred, Left, Right> : Left extends TArray<infer Items extends TSchema> ? TExtendsArray<Inferred, Left, Items, Right> : Left extends TBigInt ? TExtendsBigInt<Inferred, Left, Right> : Left extends TBoolean ? TExtendsBoolean<Inferred, Left, Right> : Left extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TExtendsConstructor<Inferred, Parameters, InstanceType, Right> : Left extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TExtendsDependent<Inferred, If, Then, Else, Right> : Left extends TEnum<infer Values extends TEnumValue[]> ? TExtendsEnum<Inferred, Values, Right> : Left extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TExtendsFunction<Inferred, Parameters, ReturnType, Right> : Left extends TInteger ? TExtendsInteger<Inferred, Left, Right> : Left extends TIntersect<infer Types extends TSchema[]> ? TExtendsIntersect<Inferred, Types, Right> : Left extends TLiteral ? TExtendsLiteral<Inferred, Left, Right> : Left extends TNever ? TExtendsNever<Inferred, Left, Right> : Left extends TNull ? TExtendsNull<Inferred, Left, Right> : Left extends TNumber ? TExtendsNumber<Inferred, Left, Right> : Left extends TObject<infer Properties extends TProperties> ? TExtendsObject<Inferred, Properties, Right> : Left extends TRecord<infer Pattern extends string, infer Value extends TSchema> ? TExtendsRecord<Inferred, Pattern, Value, Right> : Left extends TString ? TExtendsString<Inferred, Left, Right> : Left extends TSymbol ? TExtendsSymbol<Inferred, Left, Right> : Left extends TTemplateLiteral<infer Pattern extends string> ? TExtendsTemplateLiteral<Inferred, Pattern, Right> : Left extends TTuple<infer Types extends TSchema[]> ? TExtendsTuple<Inferred, Types, Right> : Left extends TUndefined ? TExtendsUndefined<Inferred, Left, Right> : Left extends TUnion<infer Types extends TSchema[]> ? TExtendsUnion<Inferred, Types, Right> : Left extends TUnknown ? TExtendsUnknown<Inferred, Left, Right> : Left extends TVoid ? TExtendsVoid<Inferred, Left, Right> : Result.TExtendsFalse);
|
|
59
53
|
export declare function ExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsLeft<Inferred, Left, Right>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { ExtendsAny } from './any.mjs';
|
|
3
3
|
import { ExtendsArray } from './array.mjs';
|
|
4
|
-
import { ExtendsAsyncIterator } from './async_iterator.mjs';
|
|
5
4
|
import { ExtendsBigInt } from './bigint.mjs';
|
|
6
5
|
import { ExtendsBoolean } from './boolean.mjs';
|
|
7
6
|
import { ExtendsConstructor } from './constructor.mjs';
|
|
@@ -10,13 +9,11 @@ import { ExtendsEnum } from './enum.mjs';
|
|
|
10
9
|
import { ExtendsFunction } from './function.mjs';
|
|
11
10
|
import { ExtendsInteger } from './integer.mjs';
|
|
12
11
|
import { ExtendsIntersect } from './intersect.mjs';
|
|
13
|
-
import { ExtendsIterator } from './iterator.mjs';
|
|
14
12
|
import { ExtendsLiteral } from './literal.mjs';
|
|
15
13
|
import { ExtendsNever } from './never.mjs';
|
|
16
14
|
import { ExtendsNull } from './null.mjs';
|
|
17
15
|
import { ExtendsNumber } from './number.mjs';
|
|
18
16
|
import { ExtendsObject } from './object.mjs';
|
|
19
|
-
import { ExtendsPromise } from './promise.mjs';
|
|
20
17
|
import { ExtendsRecord } from './record.mjs';
|
|
21
18
|
import { ExtendsString } from './string.mjs';
|
|
22
19
|
import { ExtendsSymbol } from './symbol.mjs';
|
|
@@ -31,7 +28,6 @@ import { ExtendsVoid } from './void.mjs';
|
|
|
31
28
|
// ----------------------------------------------------------------------------
|
|
32
29
|
import { IsAny } from '../types/any.mjs';
|
|
33
30
|
import { IsArray } from '../types/array.mjs';
|
|
34
|
-
import { IsAsyncIterator } from '../types/async_iterator.mjs';
|
|
35
31
|
import { IsBigInt } from '../types/bigint.mjs';
|
|
36
32
|
import { IsBoolean } from '../types/boolean.mjs';
|
|
37
33
|
import { IsConstructor } from '../types/constructor.mjs';
|
|
@@ -40,13 +36,11 @@ import { IsEnum } from '../types/enum.mjs';
|
|
|
40
36
|
import { IsFunction } from '../types/function.mjs';
|
|
41
37
|
import { IsInteger } from '../types/integer.mjs';
|
|
42
38
|
import { IsIntersect } from '../types/intersect.mjs';
|
|
43
|
-
import { IsIterator } from '../types/iterator.mjs';
|
|
44
39
|
import { IsLiteral } from '../types/literal.mjs';
|
|
45
40
|
import { IsNever } from '../types/never.mjs';
|
|
46
41
|
import { IsNull } from '../types/null.mjs';
|
|
47
42
|
import { IsNumber } from '../types/number.mjs';
|
|
48
43
|
import { IsObject } from '../types/object.mjs';
|
|
49
|
-
import { IsPromise } from '../types/promise.mjs';
|
|
50
44
|
import { IsRecord, RecordPattern, RecordValue } from '../types/record.mjs';
|
|
51
45
|
import { IsString } from '../types/string.mjs';
|
|
52
46
|
import { IsSymbol } from '../types/symbol.mjs';
|
|
@@ -60,30 +54,27 @@ import * as Result from './result.mjs';
|
|
|
60
54
|
export function ExtendsLeft(inferred, left, right) {
|
|
61
55
|
return (IsAny(left) ? ExtendsAny(inferred, left, right) :
|
|
62
56
|
IsArray(left) ? ExtendsArray(inferred, left, left.items, right) :
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
IsUnknown(left) ? ExtendsUnknown(inferred, left, right) :
|
|
87
|
-
IsVoid(left) ? ExtendsVoid(inferred, left, right) :
|
|
88
|
-
Result.ExtendsFalse());
|
|
57
|
+
IsBigInt(left) ? ExtendsBigInt(inferred, left, right) :
|
|
58
|
+
IsBoolean(left) ? ExtendsBoolean(inferred, left, right) :
|
|
59
|
+
IsConstructor(left) ? ExtendsConstructor(inferred, left.parameters, left.instanceType, right) :
|
|
60
|
+
IsDependent(left) ? ExtendsDependent(inferred, left.if, left.then, left.else, right) :
|
|
61
|
+
IsEnum(left) ? ExtendsEnum(inferred, left.enum, right) :
|
|
62
|
+
IsFunction(left) ? ExtendsFunction(inferred, left.parameters, left.returnType, right) :
|
|
63
|
+
IsInteger(left) ? ExtendsInteger(inferred, left, right) :
|
|
64
|
+
IsIntersect(left) ? ExtendsIntersect(inferred, left.allOf, right) :
|
|
65
|
+
IsLiteral(left) ? ExtendsLiteral(inferred, left, right) :
|
|
66
|
+
IsNever(left) ? ExtendsNever(inferred, left, right) :
|
|
67
|
+
IsNull(left) ? ExtendsNull(inferred, left, right) :
|
|
68
|
+
IsNumber(left) ? ExtendsNumber(inferred, left, right) :
|
|
69
|
+
IsObject(left) ? ExtendsObject(inferred, left.properties, right) :
|
|
70
|
+
IsRecord(left) ? ExtendsRecord(inferred, RecordPattern(left), RecordValue(left), right) :
|
|
71
|
+
IsString(left) ? ExtendsString(inferred, left, right) :
|
|
72
|
+
IsSymbol(left) ? ExtendsSymbol(inferred, left, right) :
|
|
73
|
+
IsTemplateLiteral(left) ? ExtendsTemplateLiteral(inferred, left.pattern, right) :
|
|
74
|
+
IsTuple(left) ? ExtendsTuple(inferred, left.items, right) :
|
|
75
|
+
IsUndefined(left) ? ExtendsUndefined(inferred, left, right) :
|
|
76
|
+
IsUnion(left) ? ExtendsUnion(inferred, left.anyOf, right) :
|
|
77
|
+
IsUnknown(left) ? ExtendsUnknown(inferred, left, right) :
|
|
78
|
+
IsVoid(left) ? ExtendsVoid(inferred, left, right) :
|
|
79
|
+
Result.ExtendsFalse());
|
|
89
80
|
}
|
|
@@ -7,18 +7,6 @@ type TIntrinsicOrCall<Target extends string, Parameters extends T.TSchema[]> = (
|
|
|
7
7
|
] extends ['Array', [infer Type extends T.TSchema]] ? T.TArray<Type> : [
|
|
8
8
|
Target,
|
|
9
9
|
Parameters
|
|
10
|
-
] extends ['AsyncIterator', [infer Type extends T.TSchema]] ? T.TAsyncIterator<Type> : [
|
|
11
|
-
Target,
|
|
12
|
-
Parameters
|
|
13
|
-
] extends ['Promise', [infer Type extends T.TSchema]] ? T.TPromise<Type> : [
|
|
14
|
-
Target,
|
|
15
|
-
Parameters
|
|
16
|
-
] extends ['Iterator', [infer Type extends T.TSchema]] ? T.TIterator<Type> : [
|
|
17
|
-
Target,
|
|
18
|
-
Parameters
|
|
19
|
-
] extends ['Awaited', [infer Type extends T.TSchema]] ? S.TAwaitedDeferred<Type> : [
|
|
20
|
-
Target,
|
|
21
|
-
Parameters
|
|
22
10
|
] extends ['Capitalize', [infer Type extends T.TSchema]] ? S.TCapitalizeDeferred<Type> : [
|
|
23
11
|
Target,
|
|
24
12
|
Parameters
|
|
@@ -9,31 +9,27 @@ function IntrinsicOrCall(ref, parameters) {
|
|
|
9
9
|
//
|
|
10
10
|
// Have extensively tested but reports show no Omit coverage (review)
|
|
11
11
|
return (Guard.IsEqual(ref, 'Array') ? T.Array(parameters[0]) :
|
|
12
|
-
Guard.IsEqual(ref, '
|
|
13
|
-
Guard.IsEqual(ref, '
|
|
14
|
-
Guard.IsEqual(ref, '
|
|
15
|
-
Guard.IsEqual(ref, '
|
|
16
|
-
Guard.IsEqual(ref, '
|
|
17
|
-
Guard.IsEqual(ref, '
|
|
18
|
-
Guard.IsEqual(ref, '
|
|
19
|
-
Guard.IsEqual(ref, '
|
|
20
|
-
Guard.IsEqual(ref, '
|
|
21
|
-
Guard.IsEqual(ref, '
|
|
22
|
-
Guard.IsEqual(ref, '
|
|
23
|
-
Guard.IsEqual(ref, '
|
|
24
|
-
Guard.IsEqual(ref, '
|
|
25
|
-
Guard.IsEqual(ref, '
|
|
26
|
-
Guard.IsEqual(ref, '
|
|
27
|
-
Guard.IsEqual(ref, '
|
|
28
|
-
Guard.IsEqual(ref, '
|
|
29
|
-
Guard.IsEqual(ref, '
|
|
30
|
-
Guard.IsEqual(ref, '
|
|
31
|
-
Guard.IsEqual(ref, '
|
|
32
|
-
|
|
33
|
-
Guard.IsEqual(ref, 'ReturnType') ? S.ReturnTypeDeferred(parameters[0]) :
|
|
34
|
-
Guard.IsEqual(ref, 'Uncapitalize') ? S.UncapitalizeDeferred(parameters[0]) :
|
|
35
|
-
Guard.IsEqual(ref, 'Uppercase') ? S.UppercaseDeferred(parameters[0]) :
|
|
36
|
-
T.CallConstruct(T.Ref(ref), parameters));
|
|
12
|
+
Guard.IsEqual(ref, 'Capitalize') ? S.CapitalizeDeferred(parameters[0]) :
|
|
13
|
+
Guard.IsEqual(ref, 'ConstructorParameters') ? S.ConstructorParametersDeferred(parameters[0]) :
|
|
14
|
+
Guard.IsEqual(ref, 'Evaluate') ? S.EvaluateDeferred(parameters[0]) :
|
|
15
|
+
Guard.IsEqual(ref, 'Exclude') ? S.ExcludeDeferred(parameters[0], parameters[1]) :
|
|
16
|
+
Guard.IsEqual(ref, 'Extract') ? S.ExtractDeferred(parameters[0], parameters[1]) :
|
|
17
|
+
Guard.IsEqual(ref, 'Index') ? S.IndexDeferred(parameters[0], parameters[1]) :
|
|
18
|
+
Guard.IsEqual(ref, 'InstanceType') ? S.InstanceTypeDeferred(parameters[0]) :
|
|
19
|
+
Guard.IsEqual(ref, 'Lowercase') ? S.LowercaseDeferred(parameters[0]) :
|
|
20
|
+
Guard.IsEqual(ref, 'NonNullable') ? S.NonNullableDeferred(parameters[0]) :
|
|
21
|
+
Guard.IsEqual(ref, 'Omit') ? S.OmitDeferred(parameters[0], parameters[1]) :
|
|
22
|
+
Guard.IsEqual(ref, 'Parameters') ? S.ParametersDeferred(parameters[0]) :
|
|
23
|
+
Guard.IsEqual(ref, 'Partial') ? S.PartialDeferred(parameters[0]) :
|
|
24
|
+
Guard.IsEqual(ref, 'Pick') ? S.PickDeferred(parameters[0], parameters[1]) :
|
|
25
|
+
Guard.IsEqual(ref, 'Readonly') ? S.ReadonlyObjectDeferred(parameters[0]) :
|
|
26
|
+
Guard.IsEqual(ref, 'KeyOf') ? S.KeyOfDeferred(parameters[0]) :
|
|
27
|
+
Guard.IsEqual(ref, 'Record') ? T.RecordDeferred(parameters[0], parameters[1]) :
|
|
28
|
+
Guard.IsEqual(ref, 'Required') ? S.RequiredDeferred(parameters[0]) :
|
|
29
|
+
Guard.IsEqual(ref, 'ReturnType') ? S.ReturnTypeDeferred(parameters[0]) :
|
|
30
|
+
Guard.IsEqual(ref, 'Uncapitalize') ? S.UncapitalizeDeferred(parameters[0]) :
|
|
31
|
+
Guard.IsEqual(ref, 'Uppercase') ? S.UppercaseDeferred(parameters[0]) :
|
|
32
|
+
T.CallConstruct(T.Ref(ref), parameters));
|
|
37
33
|
// deno-coverage-ignore-stop
|
|
38
34
|
}
|
|
39
35
|
// ------------------------------------------------------------------
|
|
@@ -18,8 +18,6 @@ export interface TRefinement<Value extends unknown = unknown> {
|
|
|
18
18
|
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>, error: TRefineErrorCallback<Value>): TRefineAdd<Type>;
|
|
19
19
|
/** Refines a type with an explicit check */
|
|
20
20
|
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>): TRefineAdd<Type>;
|
|
21
|
-
/** @deprecated Use the error callback signature to generate error message. This overload will be removed in the next version */
|
|
22
|
-
export declare function Refine<Type extends TSchema, Value = Static<Type>>(type: Type, check: TRefineCheckCallback<Value>, message: string): TRefineAdd<Type>;
|
|
23
21
|
/** Returns true if the given value is a TRefinement. */
|
|
24
22
|
export declare function IsRefinement(value: unknown): value is TRefinement;
|
|
25
23
|
/** Returns true if the given value is a TRefine. */
|
|
@@ -10,11 +10,10 @@ export function RefineAdd(type, refinement) {
|
|
|
10
10
|
}
|
|
11
11
|
/** Refines a type with an explicit check */
|
|
12
12
|
export function Refine(...args) {
|
|
13
|
-
const [type, check,
|
|
13
|
+
const [type, check, error] = Arguments.Match(args, {
|
|
14
14
|
3: (type, check, error) => [type, check, error],
|
|
15
15
|
2: (type, check) => [type, check, () => 'Refine Error'],
|
|
16
16
|
});
|
|
17
|
-
const error = Guard.IsString(error_or_message) ? () => error_or_message : error_or_message;
|
|
18
17
|
return RefineAdd(type, { check, error });
|
|
19
18
|
}
|
|
20
19
|
// ------------------------------------------------------------------
|
|
@@ -5,8 +5,6 @@ export * from './_readonly.mjs';
|
|
|
5
5
|
export * from './_refine.mjs';
|
|
6
6
|
export * from './any.mjs';
|
|
7
7
|
export * from './array.mjs';
|
|
8
|
-
export * from './async_iterator.mjs';
|
|
9
|
-
export * from './base.mjs';
|
|
10
8
|
export * from './bigint.mjs';
|
|
11
9
|
export * from './boolean.mjs';
|
|
12
10
|
export * from './call.mjs';
|
|
@@ -21,7 +19,6 @@ export * from './dependent.mjs';
|
|
|
21
19
|
export * from './infer.mjs';
|
|
22
20
|
export * from './integer.mjs';
|
|
23
21
|
export * from './intersect.mjs';
|
|
24
|
-
export * from './iterator.mjs';
|
|
25
22
|
export * from './literal.mjs';
|
|
26
23
|
export * from './never.mjs';
|
|
27
24
|
export * from './null.mjs';
|
|
@@ -30,7 +27,6 @@ export * from './unknown.mjs';
|
|
|
30
27
|
export * from './symbol.mjs';
|
|
31
28
|
export * from './object.mjs';
|
|
32
29
|
export * from './parameter.mjs';
|
|
33
|
-
export * from './promise.mjs';
|
|
34
30
|
export * from './properties.mjs';
|
|
35
31
|
export * from './record.mjs';
|
|
36
32
|
export * from './ref.mjs';
|
|
@@ -11,8 +11,6 @@ export * from './_refine.mjs';
|
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
export * from './any.mjs';
|
|
13
13
|
export * from './array.mjs';
|
|
14
|
-
export * from './async_iterator.mjs';
|
|
15
|
-
export * from './base.mjs';
|
|
16
14
|
export * from './bigint.mjs';
|
|
17
15
|
export * from './boolean.mjs';
|
|
18
16
|
export * from './call.mjs';
|
|
@@ -27,7 +25,6 @@ export * from './dependent.mjs';
|
|
|
27
25
|
export * from './infer.mjs';
|
|
28
26
|
export * from './integer.mjs';
|
|
29
27
|
export * from './intersect.mjs';
|
|
30
|
-
export * from './iterator.mjs';
|
|
31
28
|
export * from './literal.mjs';
|
|
32
29
|
export * from './never.mjs';
|
|
33
30
|
export * from './null.mjs';
|
|
@@ -36,7 +33,6 @@ export * from './unknown.mjs';
|
|
|
36
33
|
export * from './symbol.mjs';
|
|
37
34
|
export * from './object.mjs';
|
|
38
35
|
export * from './parameter.mjs';
|
|
39
|
-
export * from './promise.mjs';
|
|
40
36
|
export * from './properties.mjs';
|
|
41
37
|
export * from './record.mjs';
|
|
42
38
|
export * from './ref.mjs';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { StaticCodec, TCodec } from './_codec.mjs';
|
|
2
2
|
import type { StaticAny, TAny } from './any.mjs';
|
|
3
3
|
import type { StaticArray, TArray } from './array.mjs';
|
|
4
|
-
import type { StaticAsyncIterator, TAsyncIterator } from './async_iterator.mjs';
|
|
5
|
-
import type { StaticBase, Base } from './base.mjs';
|
|
6
4
|
import type { StaticBigInt, TBigInt } from './bigint.mjs';
|
|
7
5
|
import type { StaticBoolean, TBoolean } from './boolean.mjs';
|
|
8
6
|
import type { StaticConstructor, TConstructor } from './constructor.mjs';
|
|
@@ -12,13 +10,11 @@ import type { StaticFunction, TFunction } from './function.mjs';
|
|
|
12
10
|
import type { StaticInteger, TInteger } from './integer.mjs';
|
|
13
11
|
import type { StaticDependent, TDependent } from './dependent.mjs';
|
|
14
12
|
import type { StaticIntersect, TIntersect } from './intersect.mjs';
|
|
15
|
-
import type { StaticIterator, TIterator } from './iterator.mjs';
|
|
16
13
|
import type { StaticLiteral, TLiteral, TLiteralValue } from './literal.mjs';
|
|
17
14
|
import type { StaticNever, TNever } from './never.mjs';
|
|
18
15
|
import type { StaticNull, TNull } from './null.mjs';
|
|
19
16
|
import type { StaticNumber, TNumber } from './number.mjs';
|
|
20
17
|
import type { StaticObject, TObject } from './object.mjs';
|
|
21
|
-
import type { StaticPromise, TPromise } from './promise.mjs';
|
|
22
18
|
import type { TProperties } from './properties.mjs';
|
|
23
19
|
import type { StaticRecord, TRecord } from './record.mjs';
|
|
24
20
|
import type { StaticRef, TRef } from './ref.mjs';
|
|
@@ -38,7 +34,7 @@ export type StaticEvaluate<T> = {
|
|
|
38
34
|
[K in keyof T]: T[K];
|
|
39
35
|
} & {};
|
|
40
36
|
export type StaticDirection = 'Encode' | 'Decode';
|
|
41
|
-
export type StaticType<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema> = (Type extends TCodec<infer Type extends TSchema, infer Decoded extends unknown> ? StaticCodec<Stack, Direction, Context, This, Type, Decoded> : Type extends TAny ? StaticAny : Type extends TArray<infer Items extends TSchema> ? StaticArray<Stack, Direction, Context, This, Type, Items> : Type extends
|
|
37
|
+
export type StaticType<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Type extends TSchema> = (Type extends TCodec<infer Type extends TSchema, infer Decoded extends unknown> ? StaticCodec<Stack, Direction, Context, This, Type, Decoded> : Type extends TAny ? StaticAny : Type extends TArray<infer Items extends TSchema> ? StaticArray<Stack, Direction, Context, This, Type, Items> : Type extends TBigInt ? StaticBigInt : Type extends TBoolean ? StaticBoolean : Type extends TConstructor<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticConstructor<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TEnum<infer Values extends TEnumValue[]> ? StaticEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? StaticFunction<Stack, Direction, Context, This, Parameters, ReturnType> : Type extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? StaticDependent<Stack, Direction, Context, This, If, Then, Else> : Type extends TInteger ? StaticInteger : Type extends TIntersect<infer Types extends TSchema[]> ? StaticIntersect<Stack, Direction, Context, This, Types> : Type extends TLiteral<infer Value extends TLiteralValue> ? StaticLiteral<Value> : Type extends TNever ? StaticNever : Type extends TNull ? StaticNull : Type extends TNumber ? StaticNumber : Type extends TObject<infer Properties extends TProperties> ? StaticObject<Stack, Direction, Context, This, Properties> : Type extends TRecord<infer Key extends string, infer Value extends TSchema> ? StaticRecord<Stack, Direction, Context, This, Key, Value> : Type extends TCyclic<infer Defs extends TProperties, infer Ref extends string> ? StaticCyclic<Stack, Direction, Context, This, Defs, Ref> : Type extends TRef<infer Ref extends string> ? StaticRef<Stack, Direction, Context, This, Ref> : Type extends TString ? StaticString : Type extends TSymbol ? StaticSymbol : Type extends TTemplateLiteral<infer Pattern extends string> ? StaticTemplateLiteral<Pattern> : Type extends TThis ? StaticThis<Stack, Direction, Context, This> : Type extends TTuple<infer Items extends TSchema[]> ? StaticTuple<Stack, Direction, Context, This, Type, Items> : Type extends TUndefined ? StaticUndefined : Type extends TUnion<infer Types extends TSchema[]> ? StaticUnion<Stack, Direction, Context, This, Types> : Type extends TUnknown ? StaticUnknown : Type extends TUnsafe<infer Type extends unknown> ? StaticUnsafe<Type> : Type extends TVoid ? StaticVoid : XStatic<Type>);
|
|
42
38
|
/** Infers a static type from a TypeBox type using Parse logic. */
|
|
43
39
|
export type StaticParse<Type extends TSchema, Context extends TProperties = {}, Result extends unknown = StaticType<[], 'Encode', Context, {}, Type>> = Result;
|
|
44
40
|
/** Infers a static type from a TypeBox type using Decode logic. */
|