typebox 1.1.39 → 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 +4 -7
- package/build/type/script/mapping.mjs +16 -16
- package/build/type/script/parser.d.mts +3 -3
- package/build/type/script/parser.mjs +2 -2
- 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 +1 -1
- 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
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
// deno-lint-ignore-file ban-types
|
|
2
2
|
// deno-fmt-ignore-file
|
|
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 { Object, IsObject } from '../../types/object.mjs';
|
|
6
7
|
import { IsUnion } from '../../types/union.mjs';
|
|
7
8
|
import { FromCyclic } from './from_cyclic.mjs';
|
|
9
|
+
import { FromDependent } from './from_dependent.mjs';
|
|
8
10
|
import { FromIntersect } from './from_intersect.mjs';
|
|
9
11
|
import { FromUnion } from './from_union.mjs';
|
|
10
12
|
import { FromObject } from './from_object.mjs';
|
|
11
13
|
export function FromType(type) {
|
|
12
14
|
return (IsCyclic(type) ? FromCyclic(type.$defs, type.$ref) :
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
IsDependent(type) ? FromDependent(type.if, type.then, type.else) :
|
|
16
|
+
IsIntersect(type) ? FromIntersect(type.allOf) :
|
|
17
|
+
IsUnion(type) ? FromUnion(type.anyOf) :
|
|
18
|
+
IsObject(type) ? FromObject(type.properties) :
|
|
19
|
+
Object({}));
|
|
17
20
|
}
|
|
@@ -9,7 +9,7 @@ import { type TNumber, NumberPattern } from '../../types/number.mjs';
|
|
|
9
9
|
import { type TInteger, IntegerPattern } from '../../types/integer.mjs';
|
|
10
10
|
import { type TBoolean } from '../../types/boolean.mjs';
|
|
11
11
|
import { NeverPattern } from '../../types/never.mjs';
|
|
12
|
-
import { type
|
|
12
|
+
import { type TEvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
13
13
|
import { type TTemplateLiteralAction } from './instantiate.mjs';
|
|
14
14
|
type TJoinString<Input extends string[], Result extends string = ''> = (Input extends [infer Left extends string, ...infer Right extends string[]] ? Result extends '' ? TJoinString<Right, Left> : TJoinString<Right, `${Result}|${Left}`> : Result);
|
|
15
15
|
type TUnwrapTemplateLiteralPattern<Pattern extends string> = (Pattern extends `^${infer Pattern extends string}$` ? Pattern : never);
|
|
@@ -21,7 +21,7 @@ type TEncodeBoolean<Right extends TSchema[], Pattern extends string> = (TEncodeT
|
|
|
21
21
|
type TEncodeString<Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${typeof StringPattern}`>);
|
|
22
22
|
type TEncodeTemplateLiteral<TemplatePattern extends string, Right extends TSchema[], Pattern extends string> = (TEncodeTypes<Right, `${Pattern}${TUnwrapTemplateLiteralPattern<TemplatePattern>}`>);
|
|
23
23
|
type TEncodeTemplateLiteralDeferred<Types extends TSchema[], Right extends TSchema[], Pattern extends string, TemplateLiteral extends TSchema = TTemplateLiteralAction<Types>, Result extends TSchema = TEncodeType<TemplateLiteral, Right, Pattern>> = Result;
|
|
24
|
-
type TEncodeEnum<
|
|
24
|
+
type TEncodeEnum<Values extends TEnumValue[], Right extends TSchema[], Pattern extends string, Evaluated extends TSchema = TEvaluateEnum<Values>> = TEncodeType<Evaluated, Right, Pattern>;
|
|
25
25
|
type TEncodeUnion<Types extends TSchema[], Right extends TSchema[], Pattern extends string, Result extends string[] = []> = Types extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TEncodeUnion<Tail, Right, Pattern, [...Result, TEncodeType<Head, [], ''>]> : TEncodeTypes<Right, `${Pattern}(${TJoinString<Result>})`>;
|
|
26
26
|
type TEncodeType<Type extends TSchema, Right extends TSchema[], Pattern extends string> = (Type extends TEnum<infer Values extends TEnumValue[]> ? TEncodeEnum<Values, Right, Pattern> : Type extends TInteger ? TEncodeInteger<Right, Pattern> : Type extends TLiteral<infer Value extends TLiteralValue> ? TEncodeLiteral<Value, Right, Pattern> : Type extends TBigInt ? TEncodeBigInt<Right, Pattern> : Type extends TBoolean ? TEncodeBoolean<Right, Pattern> : Type extends TNumber ? TEncodeNumber<Right, Pattern> : Type extends TString ? TEncodeString<Right, Pattern> : Type extends TTemplateLiteral<infer TemplatePattern extends string> ? TEncodeTemplateLiteral<TemplatePattern, Right, Pattern> : Type extends TTemplateLiteralDeferred<infer Types extends TSchema[]> ? TEncodeTemplateLiteralDeferred<Types, Right, Pattern> : Type extends TUnion<infer Types extends TSchema[]> ? TEncodeUnion<Types, Right, Pattern> : typeof NeverPattern);
|
|
27
27
|
type TEncodeTypes<Types extends TSchema[], Pattern extends string> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TEncodeType<Left, Right, Pattern> : Pattern);
|
|
@@ -11,7 +11,7 @@ import { IsInteger, IntegerPattern } from '../../types/integer.mjs';
|
|
|
11
11
|
import { IsBoolean } from '../../types/boolean.mjs';
|
|
12
12
|
import { NeverPattern } from '../../types/never.mjs';
|
|
13
13
|
import { TemplateLiteralCreate } from './create.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { EvaluateEnum } from '../evaluate/evaluate.mjs';
|
|
15
15
|
import { TemplateLiteralAction } from './instantiate.mjs';
|
|
16
16
|
function JoinString(input) {
|
|
17
17
|
return input.join('|');
|
|
@@ -45,9 +45,9 @@ function EncodeTemplateLiteralDeferred(types, right, pattern) {
|
|
|
45
45
|
const result = EncodeType(templateLiteral, right, pattern);
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
|
-
function EncodeEnum(
|
|
49
|
-
const
|
|
50
|
-
return
|
|
48
|
+
function EncodeEnum(values, right, pattern) {
|
|
49
|
+
const evaluated = EvaluateEnum(values);
|
|
50
|
+
return EncodeType(evaluated, right, pattern);
|
|
51
51
|
}
|
|
52
52
|
function EncodeUnion(types, right, pattern, result = []) {
|
|
53
53
|
return Guard.TakeLeft(types, (head, tail) => EncodeUnion(tail, right, pattern, [...result, EncodeType(head, [], '')]), () => EncodeTypes(right, `${pattern}(${JoinString(result)})`));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TProperties } from '../../types/properties.mjs';
|
|
2
|
+
import { type TSchema } from '../../types/schema.mjs';
|
|
3
|
+
import { type TState, type TInstantiateType, type TCanInstantiate } from '../instantiate.mjs';
|
|
4
|
+
import { type TWithDeferred, type TWith } from '../../action/with.mjs';
|
|
5
|
+
export type TWithAction<Type extends TSchema, Options extends TSchema, Result extends TSchema = TCanInstantiate<[Type]> extends true ? TWith<Type, Options> : TWithDeferred<Type, Options>> = Result;
|
|
6
|
+
export declare function WithAction<Type extends TSchema, Options extends TSchema>(type: Type, options: Options): TWithAction<Type, Options>;
|
|
7
|
+
export type TWithInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Options extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>> = TWithAction<InstantiatedType, Options>;
|
|
8
|
+
export declare function WithInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Options extends TSchema>(context: Context, state: State, type: Type, options: Options): TWithInstantiate<Context, State, Type, Options>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Memory } from '../../../system/memory/index.mjs';
|
|
3
3
|
import { InstantiateType, CanInstantiate } from '../instantiate.mjs';
|
|
4
|
-
import {
|
|
5
|
-
export function
|
|
4
|
+
import { WithDeferred } from '../../action/with.mjs';
|
|
5
|
+
export function WithAction(type, options) {
|
|
6
6
|
const result = CanInstantiate([type])
|
|
7
7
|
? Memory.Update(type, {}, options)
|
|
8
|
-
:
|
|
8
|
+
: WithDeferred(type, options);
|
|
9
9
|
return result;
|
|
10
10
|
}
|
|
11
|
-
export function
|
|
11
|
+
export function WithInstantiate(context, state, type, options) {
|
|
12
12
|
const instaniatedType = InstantiateType(context, state, type);
|
|
13
|
-
return
|
|
13
|
+
return WithAction(instaniatedType, options);
|
|
14
14
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TProperties } from '../types/properties.mjs';
|
|
2
|
+
import { type TSchema } from '../types/schema.mjs';
|
|
3
|
+
import { type TExtendsLeft } from './extends_left.mjs';
|
|
4
|
+
import * as Result from './result.mjs';
|
|
5
|
+
export type TExtendsDependent<Inferred extends TProperties, If extends TSchema, Then extends TSchema, Else extends TSchema, Right extends TSchema> = (TExtendsLeft<Inferred, If, Right> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsLeft<Inferred, Then, Right> : TExtendsLeft<Inferred, Else, Right>);
|
|
6
|
+
export declare function ExtendsDependent<Inferred extends TProperties, If extends TSchema, Then extends TSchema, Else extends TSchema, Right extends TSchema>(inferred: Inferred, if_: If, then_: Then, else_: Else, right: Right): TExtendsDependent<Inferred, If, Then, Else, Right>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { ExtendsLeft } from './extends_left.mjs';
|
|
3
|
+
import * as Result from './result.mjs';
|
|
4
|
+
export function ExtendsDependent(inferred, if_, then_, else_, right) {
|
|
5
|
+
return Result.Match(ExtendsLeft(inferred, if_, right), () => ExtendsLeft(inferred, then_, right), () => ExtendsLeft(inferred, else_, right));
|
|
6
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type TSchema } from '../types/schema.mjs';
|
|
2
2
|
import { type TProperties } from '../types/properties.mjs';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TEnumValue } from '../types/enum.mjs';
|
|
4
4
|
import { type TExtendsLeft } from './extends_left.mjs';
|
|
5
|
-
import { type
|
|
6
|
-
export type TExtendsEnum<Inferred extends TProperties, Left extends
|
|
7
|
-
export declare function ExtendsEnum<Inferred extends TProperties, Left extends
|
|
5
|
+
import { type TEvaluateEnum } from '../engine/evaluate/evaluate.mjs';
|
|
6
|
+
export type TExtendsEnum<Inferred extends TProperties, Left extends TEnumValue[], Right extends TSchema, Evaluated extends TSchema = TEvaluateEnum<Left>> = TExtendsLeft<Inferred, Evaluated, Right>;
|
|
7
|
+
export declare function ExtendsEnum<Inferred extends TProperties, Left extends TEnumValue[], Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsEnum<Inferred, Left, Right>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { ExtendsLeft } from './extends_left.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { EvaluateEnum } from '../engine/evaluate/evaluate.mjs';
|
|
4
4
|
export function ExtendsEnum(inferred, left, right) {
|
|
5
|
-
|
|
5
|
+
const evaluated = EvaluateEnum(left);
|
|
6
|
+
return ExtendsLeft(inferred, evaluated, right);
|
|
6
7
|
}
|
|
@@ -4,6 +4,7 @@ import { type TExtendsAsyncIterator } from './async_iterator.mjs';
|
|
|
4
4
|
import { type TExtendsBigInt } from './bigint.mjs';
|
|
5
5
|
import { type TExtendsBoolean } from './boolean.mjs';
|
|
6
6
|
import { type TExtendsConstructor } from './constructor.mjs';
|
|
7
|
+
import { type TExtendsDependent } from './dependent.mjs';
|
|
7
8
|
import { type TExtendsEnum } from './enum.mjs';
|
|
8
9
|
import { type TExtendsFunction } from './function.mjs';
|
|
9
10
|
import { type TExtendsInteger } from './integer.mjs';
|
|
@@ -29,6 +30,7 @@ import { type TAsyncIterator } from '../types/async_iterator.mjs';
|
|
|
29
30
|
import { type TBigInt } from '../types/bigint.mjs';
|
|
30
31
|
import { type TBoolean } from '../types/boolean.mjs';
|
|
31
32
|
import { type TConstructor } from '../types/constructor.mjs';
|
|
33
|
+
import { type TDependent } from '../types/dependent.mjs';
|
|
32
34
|
import { type TEnum, type TEnumValue } from '../types/enum.mjs';
|
|
33
35
|
import { type TFunction } from '../types/function.mjs';
|
|
34
36
|
import { type TInteger } from '../types/integer.mjs';
|
|
@@ -51,5 +53,5 @@ import { type TProperties } from '../types/properties.mjs';
|
|
|
51
53
|
import { type TUnion } from '../types/union.mjs';
|
|
52
54
|
import { type TVoid } from '../types/void.mjs';
|
|
53
55
|
import * as Result from './result.mjs';
|
|
54
|
-
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 TAsyncIterator<infer Type extends TSchema> ? TExtendsAsyncIterator<Inferred, Type, 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 TEnum<infer Values extends TEnumValue[]> ? TExtendsEnum<Inferred,
|
|
56
|
+
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 TAsyncIterator<infer Type extends TSchema> ? TExtendsAsyncIterator<Inferred, Type, 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 TIterator<infer Type extends TSchema> ? TExtendsIterator<Inferred, Type, 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 TPromise<infer Type extends TSchema> ? TExtendsPromise<Inferred, Type, 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);
|
|
55
57
|
export declare function ExtendsLeft<Inferred extends TProperties, Left extends TSchema, Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsLeft<Inferred, Left, Right>;
|
|
@@ -5,6 +5,7 @@ import { ExtendsAsyncIterator } from './async_iterator.mjs';
|
|
|
5
5
|
import { ExtendsBigInt } from './bigint.mjs';
|
|
6
6
|
import { ExtendsBoolean } from './boolean.mjs';
|
|
7
7
|
import { ExtendsConstructor } from './constructor.mjs';
|
|
8
|
+
import { ExtendsDependent } from './dependent.mjs';
|
|
8
9
|
import { ExtendsEnum } from './enum.mjs';
|
|
9
10
|
import { ExtendsFunction } from './function.mjs';
|
|
10
11
|
import { ExtendsInteger } from './integer.mjs';
|
|
@@ -33,6 +34,7 @@ import { IsAsyncIterator } from '../types/async_iterator.mjs';
|
|
|
33
34
|
import { IsBigInt } from '../types/bigint.mjs';
|
|
34
35
|
import { IsBoolean } from '../types/boolean.mjs';
|
|
35
36
|
import { IsConstructor } from '../types/constructor.mjs';
|
|
37
|
+
import { IsDependent } from '../types/dependent.mjs';
|
|
36
38
|
import { IsEnum } from '../types/enum.mjs';
|
|
37
39
|
import { IsFunction } from '../types/function.mjs';
|
|
38
40
|
import { IsInteger } from '../types/integer.mjs';
|
|
@@ -60,24 +62,25 @@ export function ExtendsLeft(inferred, left, right) {
|
|
|
60
62
|
IsBigInt(left) ? ExtendsBigInt(inferred, left, right) :
|
|
61
63
|
IsBoolean(left) ? ExtendsBoolean(inferred, left, right) :
|
|
62
64
|
IsConstructor(left) ? ExtendsConstructor(inferred, left.parameters, left.instanceType, right) :
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
65
|
+
IsDependent(left) ? ExtendsDependent(inferred, left.if, left.then, left.else, right) :
|
|
66
|
+
IsEnum(left) ? ExtendsEnum(inferred, left.enum, right) :
|
|
67
|
+
IsFunction(left) ? ExtendsFunction(inferred, left.parameters, left.returnType, right) :
|
|
68
|
+
IsInteger(left) ? ExtendsInteger(inferred, left, right) :
|
|
69
|
+
IsIntersect(left) ? ExtendsIntersect(inferred, left.allOf, right) :
|
|
70
|
+
IsIterator(left) ? ExtendsIterator(inferred, left.iteratorItems, right) :
|
|
71
|
+
IsLiteral(left) ? ExtendsLiteral(inferred, left, right) :
|
|
72
|
+
IsNever(left) ? ExtendsNever(inferred, left, right) :
|
|
73
|
+
IsNull(left) ? ExtendsNull(inferred, left, right) :
|
|
74
|
+
IsNumber(left) ? ExtendsNumber(inferred, left, right) :
|
|
75
|
+
IsObject(left) ? ExtendsObject(inferred, left.properties, right) :
|
|
76
|
+
IsPromise(left) ? ExtendsPromise(inferred, left.item, right) :
|
|
77
|
+
IsString(left) ? ExtendsString(inferred, left, right) :
|
|
78
|
+
IsSymbol(left) ? ExtendsSymbol(inferred, left, right) :
|
|
79
|
+
IsTemplateLiteral(left) ? ExtendsTemplateLiteral(inferred, left.pattern, right) :
|
|
80
|
+
IsTuple(left) ? ExtendsTuple(inferred, left.items, right) :
|
|
81
|
+
IsUndefined(left) ? ExtendsUndefined(inferred, left, right) :
|
|
82
|
+
IsUnion(left) ? ExtendsUnion(inferred, left.anyOf, right) :
|
|
83
|
+
IsUnknown(left) ? ExtendsUnknown(inferred, left, right) :
|
|
84
|
+
IsVoid(left) ? ExtendsVoid(inferred, left, right) :
|
|
85
|
+
Result.ExtendsFalse());
|
|
83
86
|
}
|
|
@@ -2,6 +2,7 @@ import { Memory } from '../../system/memory/index.mjs';
|
|
|
2
2
|
import { type TSchema } from '../types/schema.mjs';
|
|
3
3
|
import { type TProperties } from '../types/properties.mjs';
|
|
4
4
|
import { type TAny } from '../types/any.mjs';
|
|
5
|
+
import { type TDependent } from '../types/dependent.mjs';
|
|
5
6
|
import { type TEnum, type TEnumValue } from '../types/enum.mjs';
|
|
6
7
|
import { type TInfer } from '../types/infer.mjs';
|
|
7
8
|
import { type TIntersect } from '../types/intersect.mjs';
|
|
@@ -10,16 +11,17 @@ import { type TUnion } from '../types/union.mjs';
|
|
|
10
11
|
import { type TUnknown } from '../types/unknown.mjs';
|
|
11
12
|
import { type TExtendsLeft } from './extends_left.mjs';
|
|
12
13
|
import * as Result from './result.mjs';
|
|
13
|
-
import { type
|
|
14
|
-
import { type
|
|
14
|
+
import { type TEvaluateEnum } from '../engine/evaluate/evaluate.mjs';
|
|
15
|
+
import { type TEvaluateTemplateLiteral } from '../engine/evaluate/evaluate.mjs';
|
|
15
16
|
type TExtendsRightInfer<Inferred extends TProperties, Name extends string, Left extends TSchema, Right extends TSchema, Result extends Result.TResult = (TExtendsLeft<Inferred, Left, Right> extends Result.TExtendsTrueLike<infer CheckInferred extends TProperties> ? Result.TExtendsTrue<Memory.TAssign<Memory.TAssign<Inferred, CheckInferred>, {
|
|
16
17
|
[_ in Name]: Left;
|
|
17
18
|
}>> : Result.TExtendsFalse)> = Result;
|
|
18
19
|
type TExtendsRightAny<Inferred extends TProperties, _Left extends TSchema, Result extends Result.TResult = Result.TExtendsTrue<Inferred>> = Result;
|
|
19
|
-
type
|
|
20
|
+
type TExtendsRightDependent<Inferred extends TProperties, Left extends TSchema, If extends TSchema, Then extends TSchema, Else extends TSchema, Result extends Result.TResult = TExtendsLeft<Inferred, Left, If> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? (TExtendsLeft<Inferred, Left, Then> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? Result.TExtendsTrue<Inferred> : Result.TExtendsFalse) : (TExtendsLeft<Inferred, Left, Else> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? Result.TExtendsTrue<Inferred> : Result.TExtendsFalse)> = Result;
|
|
21
|
+
type TExtendsRightEnum<Inferred extends TProperties, Left extends TSchema, Right extends TEnumValue[], Evaluated extends TSchema = TEvaluateEnum<Right>> = TExtendsLeft<Inferred, Left, Evaluated>;
|
|
20
22
|
type TExtendsRightIntersect<Inferred extends TProperties, Left extends TSchema, Right extends TSchema[]> = (Right extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Left, Head> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? TExtendsRightIntersect<Inferred, Left, Tail> : Result.TExtendsFalse : Result.TExtendsTrue<Inferred>);
|
|
21
|
-
type TExtendsRightTemplateLiteral<Inferred extends TProperties, Left extends TSchema, Right extends string,
|
|
23
|
+
type TExtendsRightTemplateLiteral<Inferred extends TProperties, Left extends TSchema, Right extends string, Evaluated extends TSchema = TEvaluateTemplateLiteral<Right>> = TExtendsLeft<Inferred, Left, Evaluated>;
|
|
22
24
|
type TExtendsRightUnion<Inferred extends TProperties, Left extends TSchema, Right extends TSchema[]> = (Right extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtendsLeft<Inferred, Left, Head> extends Result.TExtendsTrueLike<infer Inferred extends TProperties> ? Result.TExtendsTrue<Inferred> : TExtendsRightUnion<Inferred, Left, Tail> : Result.TExtendsFalse);
|
|
23
|
-
export type TExtendsRight<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TAny ? TExtendsRightAny<Inferred, Left> : Right extends TEnum<infer Values extends TEnumValue[]> ? TExtendsRightEnum<Inferred, Left, Values> : Right extends TInfer<infer Name extends string, infer Type extends TSchema> ? TExtendsRightInfer<Inferred, Name, Left, Type> : Right extends TTemplateLiteral<infer Pattern extends string> ? TExtendsRightTemplateLiteral<Inferred, Left, Pattern> : Right extends TIntersect<infer Types extends TSchema[]> ? TExtendsRightIntersect<Inferred, Left, Types> : Right extends TUnion<infer Types extends TSchema[]> ? TExtendsRightUnion<Inferred, Left, Types> : Right extends TUnknown ? Result.TExtendsTrue<Inferred> : Result.TExtendsFalse);
|
|
25
|
+
export type TExtendsRight<Inferred extends TProperties, Left extends TSchema, Right extends TSchema> = (Right extends TAny ? TExtendsRightAny<Inferred, Left> : Right extends TDependent<infer If extends TSchema, infer Then extends TSchema, infer Else extends TSchema> ? TExtendsRightDependent<Inferred, Left, If, Then, Else> : Right extends TEnum<infer Values extends TEnumValue[]> ? TExtendsRightEnum<Inferred, Left, Values> : Right extends TInfer<infer Name extends string, infer Type extends TSchema> ? TExtendsRightInfer<Inferred, Name, Left, Type> : Right extends TTemplateLiteral<infer Pattern extends string> ? TExtendsRightTemplateLiteral<Inferred, Left, Pattern> : Right extends TIntersect<infer Types extends TSchema[]> ? TExtendsRightIntersect<Inferred, Left, Types> : Right extends TUnion<infer Types extends TSchema[]> ? TExtendsRightUnion<Inferred, Left, Types> : Right extends TUnknown ? Result.TExtendsTrue<Inferred> : Result.TExtendsFalse);
|
|
24
26
|
export declare function ExtendsRight<Inferred extends TProperties, Left extends TSchema, Right extends TSchema>(inferred: Inferred, left: Left, right: Right): TExtendsRight<Inferred, Left, Right>;
|
|
25
27
|
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Guard } from '../../guard/index.mjs';
|
|
3
3
|
import { Memory } from '../../system/memory/index.mjs';
|
|
4
4
|
import { IsAny } from '../types/any.mjs';
|
|
5
|
+
import { IsDependent } from '../types/dependent.mjs';
|
|
5
6
|
import { IsEnum } from '../types/enum.mjs';
|
|
6
7
|
import { IsInfer } from '../types/infer.mjs';
|
|
7
8
|
import { IsIntersect } from '../types/intersect.mjs';
|
|
@@ -10,35 +11,39 @@ import { IsUnion } from '../types/union.mjs';
|
|
|
10
11
|
import { IsUnknown } from '../types/unknown.mjs';
|
|
11
12
|
import { ExtendsLeft } from './extends_left.mjs';
|
|
12
13
|
import * as Result from './result.mjs';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
14
|
+
import { EvaluateEnum } from '../engine/evaluate/evaluate.mjs';
|
|
15
|
+
import { EvaluateTemplateLiteral } from '../engine/evaluate/evaluate.mjs';
|
|
15
16
|
function ExtendsRightInfer(inferred, name, left, right) {
|
|
16
17
|
return Result.Match(ExtendsLeft(inferred, left, right), checkInferred => Result.ExtendsTrue(Memory.Assign(Memory.Assign(inferred, checkInferred), { [name]: left })), () => Result.ExtendsFalse());
|
|
17
18
|
}
|
|
18
19
|
function ExtendsRightAny(inferred, _left) {
|
|
19
20
|
return Result.ExtendsTrue(inferred);
|
|
20
21
|
}
|
|
22
|
+
function ExtendsRightDependent(inferred, left, if_, then_, else_) {
|
|
23
|
+
return Result.Match(ExtendsLeft(inferred, left, if_), inferred => Result.Match(ExtendsLeft(inferred, left, then_), inferred => Result.ExtendsTrue(inferred), () => Result.ExtendsFalse()), () => Result.Match(ExtendsLeft(inferred, left, else_), inferred => Result.ExtendsTrue(inferred), () => Result.ExtendsFalse()));
|
|
24
|
+
}
|
|
21
25
|
function ExtendsRightEnum(inferred, left, right) {
|
|
22
|
-
const
|
|
23
|
-
return ExtendsLeft(inferred, left,
|
|
26
|
+
const evaluated = EvaluateEnum(right);
|
|
27
|
+
return ExtendsLeft(inferred, left, evaluated);
|
|
24
28
|
}
|
|
25
29
|
function ExtendsRightIntersect(inferred, left, right) {
|
|
26
30
|
return Guard.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => ExtendsRightIntersect(inferred, left, tail), () => Result.ExtendsFalse()), () => Result.ExtendsTrue(inferred));
|
|
27
31
|
}
|
|
28
32
|
function ExtendsRightTemplateLiteral(inferred, left, right) {
|
|
29
|
-
const
|
|
30
|
-
return ExtendsLeft(inferred, left,
|
|
33
|
+
const evaluated = EvaluateTemplateLiteral(right);
|
|
34
|
+
return ExtendsLeft(inferred, left, evaluated);
|
|
31
35
|
}
|
|
32
36
|
function ExtendsRightUnion(inferred, left, right) {
|
|
33
37
|
return Guard.TakeLeft(right, (head, tail) => Result.Match(ExtendsLeft(inferred, left, head), inferred => Result.ExtendsTrue(inferred), () => ExtendsRightUnion(inferred, left, tail)), () => Result.ExtendsFalse());
|
|
34
38
|
}
|
|
35
39
|
export function ExtendsRight(inferred, left, right) {
|
|
36
40
|
return (IsAny(right) ? ExtendsRightAny(inferred, left) :
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Result.
|
|
41
|
+
IsDependent(right) ? ExtendsRightDependent(inferred, left, right.if, right.then, right.else) :
|
|
42
|
+
IsEnum(right) ? ExtendsRightEnum(inferred, left, right.enum) :
|
|
43
|
+
IsInfer(right) ? ExtendsRightInfer(inferred, right.name, left, right.extends) :
|
|
44
|
+
IsIntersect(right) ? ExtendsRightIntersect(inferred, left, right.allOf) :
|
|
45
|
+
IsTemplateLiteral(right) ? ExtendsRightTemplateLiteral(inferred, left, right.pattern) :
|
|
46
|
+
IsUnion(right) ? ExtendsRightUnion(inferred, left, right.anyOf) :
|
|
47
|
+
IsUnknown(right) ? Result.ExtendsTrue(inferred) :
|
|
48
|
+
Result.ExtendsFalse());
|
|
44
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TSchema } from '../types/schema.mjs';
|
|
2
2
|
import { type TProperties } from '../types/properties.mjs';
|
|
3
3
|
import { type TExtendsLeft } from './extends_left.mjs';
|
|
4
|
-
import { type
|
|
5
|
-
export type TExtendsTemplateLiteral<Inferred extends TProperties,
|
|
6
|
-
export declare function ExtendsTemplateLiteral<Inferred extends TProperties,
|
|
4
|
+
import { type TEvaluateTemplateLiteral } from '../engine/evaluate/evaluate.mjs';
|
|
5
|
+
export type TExtendsTemplateLiteral<Inferred extends TProperties, Pattern extends string, Right extends TSchema, Evaluated extends TSchema = TEvaluateTemplateLiteral<Pattern>> = TExtendsLeft<Inferred, Evaluated, Right>;
|
|
6
|
+
export declare function ExtendsTemplateLiteral<Inferred extends TProperties, Pattern extends string, Right extends TSchema>(inferred: Inferred, left: Pattern, right: Right): TExtendsTemplateLiteral<Inferred, Pattern, Right>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { ExtendsLeft } from './extends_left.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { EvaluateTemplateLiteral } from '../engine/evaluate/evaluate.mjs';
|
|
4
4
|
export function ExtendsTemplateLiteral(inferred, left, right) {
|
|
5
|
-
const
|
|
6
|
-
return ExtendsLeft(inferred,
|
|
5
|
+
const evaluated = EvaluateTemplateLiteral(left);
|
|
6
|
+
return ExtendsLeft(inferred, evaluated, right);
|
|
7
7
|
}
|
|
@@ -52,9 +52,6 @@ type TIntrinsicOrCall<Target extends string, Parameters extends T.TSchema[]> = (
|
|
|
52
52
|
] extends ['Omit', [infer Type extends T.TSchema, infer Indexer extends T.TSchema]] ? C.TOmitDeferred<Type, Indexer> : [
|
|
53
53
|
Target,
|
|
54
54
|
Parameters
|
|
55
|
-
] extends ['Options', [infer Type extends T.TSchema, infer Options extends T.TSchema]] ? C.TOptionsDeferred<Type, Options> : [
|
|
56
|
-
Target,
|
|
57
|
-
Parameters
|
|
58
55
|
] extends ['Parameters', [infer Type extends T.TSchema]] ? C.TParametersDeferred<Type> : [
|
|
59
56
|
Target,
|
|
60
57
|
Parameters
|
|
@@ -164,11 +161,11 @@ export type TExtendsMapping<Input extends [unknown, unknown, unknown, unknown, u
|
|
|
164
161
|
export declare function ExtendsMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | []): unknown;
|
|
165
162
|
export type TBaseMapping<Input extends [unknown, unknown, unknown] | unknown> = (Input extends ['(', infer Type extends T.TSchema, ')'] ? Type : Input extends infer Type extends T.TSchema ? Type : never);
|
|
166
163
|
export declare function BaseMapping(input: [unknown, unknown, unknown] | unknown): unknown;
|
|
167
|
-
export type TWithMapping<Input extends [unknown, unknown] | []> = (Input extends ['with', infer
|
|
164
|
+
export type TWithMapping<Input extends [unknown, unknown] | []> = (Input extends ['with', infer JsonObject extends Record<PropertyKey, unknown>] ? JsonObject : []);
|
|
168
165
|
export declare function WithMapping(input: [unknown, unknown] | []): unknown;
|
|
169
166
|
type TFactorIndexArray<Type extends T.TSchema, IndexArray extends unknown[]> = (IndexArray extends [infer Left extends T.TSchema[], ...infer Right extends unknown[]] ? (Left extends [infer Indexer extends T.TSchema] ? TFactorIndexArray<C.TIndexDeferred<Type, Indexer>, Right> : Left extends [] ? TFactorIndexArray<T.TArray<Type>, Right> : T.TNever) : Type);
|
|
170
167
|
type TFactorExtends<Type extends T.TSchema, Extends extends unknown[]> = (Extends extends [infer Right extends T.TSchema, infer True extends T.TSchema, infer False extends T.TSchema] ? C.TConditionalDeferred<Type, Right, True, False> : Type);
|
|
171
|
-
type TFactorWith<Type extends T.TSchema, With extends unknown> = (With extends Record<PropertyKey, unknown> ? C.
|
|
168
|
+
type TFactorWith<Type extends T.TSchema, With extends unknown> = (With extends Record<PropertyKey, unknown> ? C.TWithDeferred<Type, With> : Type);
|
|
172
169
|
export type TFactorMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends [infer KeyOf extends boolean, infer Type extends T.TSchema, infer IndexArray extends unknown[], infer Extend extends unknown[], infer WithClause extends unknown] ? TFactorWith<KeyOf extends true ? TFactorExtends<C.TKeyOfDeferred<TFactorIndexArray<Type, IndexArray>>, Extend> : TFactorExtends<TFactorIndexArray<Type, IndexArray>, Extend>, WithClause> : never);
|
|
173
170
|
export declare function FactorMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
174
171
|
type TExprBinaryMapping<Left extends T.TSchema, Rest extends unknown[]> = (Rest extends [infer Operator extends unknown, infer Right extends T.TSchema, infer Next extends unknown[]] ? (TExprBinaryMapping<Right, Next> extends infer Schema extends T.TSchema ? (Operator extends '&' ? (Schema extends T.TIntersect<infer Types extends T.TSchema[]> ? T.TIntersect<[Left, ...Types]> : T.TIntersect<[Left, Schema]>) : Operator extends '|' ? (Schema extends T.TUnion<infer Types extends T.TSchema[]> ? T.TUnion<[Left, ...Types]> : T.TUnion<[Left, Schema]>) : never) : never) : Left);
|
|
@@ -279,10 +276,10 @@ export type TMappedAsMapping<Input extends [unknown, unknown] | []> = (Input ext
|
|
|
279
276
|
export declare function MappedAsMapping(input: [unknown, unknown] | []): unknown;
|
|
280
277
|
export type TMappedMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]> = (Input extends ['{', infer Readonly extends TModifierOperation, '[', infer Key extends string, 'in', infer Type extends T.TSchema, infer As extends T.TSchema[], ']', infer Optional extends TModifierOperation, ':', infer Property extends T.TSchema, null, '}'] ? (As extends [infer As extends T.TSchema] ? C.TMappedDeferred<T.TIdentifier<Key>, Type, As, TApplyReadonly<Readonly, TApplyOptional<Optional, Property>>> : C.TMappedDeferred<T.TIdentifier<Key>, Type, T.TRef<Key>, TApplyReadonly<Readonly, TApplyOptional<Optional, Property>>>) : never);
|
|
281
278
|
export declare function MappedMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
279
|
+
export type TDependentMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]> = (Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema, 'else', infer Else extends T.TSchema] ? T.TDependent<If, Then, Else> : Input extends ['if', infer If extends T.TSchema, 'then', infer Then extends T.TSchema] ? T.TDependent<If, Then, T.TUnknown> : never);
|
|
280
|
+
export declare function DependentMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown]): unknown;
|
|
282
281
|
export type TReferenceMapping<Input extends string, Result extends T.TSchema = T.TRef<Input>> = Result;
|
|
283
282
|
export declare function ReferenceMapping(input: string): unknown;
|
|
284
|
-
export type TOptionsMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown]> = (Input extends ['Options', '<', infer Type extends T.TSchema, ',', infer Options extends T.TSchemaOptions, '>'] ? C.TOptionsDeferred<Type, Options> : never);
|
|
285
|
-
export declare function OptionsMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
286
283
|
export type TJsonNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? Value : never);
|
|
287
284
|
export declare function JsonNumberMapping(input: string): unknown;
|
|
288
285
|
export type TJsonBooleanMapping<Input extends 'true' | 'false'> = (Input extends 'true' ? true : false);
|
|
@@ -23,18 +23,17 @@ function IntrinsicOrCall(ref, parameters) {
|
|
|
23
23
|
Guard.IsEqual(ref, 'Lowercase') ? C.LowercaseDeferred(parameters[0]) :
|
|
24
24
|
Guard.IsEqual(ref, 'NonNullable') ? C.NonNullableDeferred(parameters[0]) :
|
|
25
25
|
Guard.IsEqual(ref, 'Omit') ? C.OmitDeferred(parameters[0], parameters[1]) :
|
|
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
|
-
Guard.IsEqual(ref, '
|
|
33
|
-
Guard.IsEqual(ref, '
|
|
34
|
-
Guard.IsEqual(ref, '
|
|
35
|
-
Guard.IsEqual(ref, '
|
|
36
|
-
|
|
37
|
-
T.CallConstruct(T.Ref(ref), parameters));
|
|
26
|
+
Guard.IsEqual(ref, 'Parameters') ? C.ParametersDeferred(parameters[0]) :
|
|
27
|
+
Guard.IsEqual(ref, 'Partial') ? C.PartialDeferred(parameters[0]) :
|
|
28
|
+
Guard.IsEqual(ref, 'Pick') ? C.PickDeferred(parameters[0], parameters[1]) :
|
|
29
|
+
Guard.IsEqual(ref, 'Readonly') ? C.ReadonlyObjectDeferred(parameters[0]) :
|
|
30
|
+
Guard.IsEqual(ref, 'KeyOf') ? C.KeyOfDeferred(parameters[0]) :
|
|
31
|
+
Guard.IsEqual(ref, 'Record') ? T.RecordDeferred(parameters[0], parameters[1]) :
|
|
32
|
+
Guard.IsEqual(ref, 'Required') ? C.RequiredDeferred(parameters[0]) :
|
|
33
|
+
Guard.IsEqual(ref, 'ReturnType') ? C.ReturnTypeDeferred(parameters[0]) :
|
|
34
|
+
Guard.IsEqual(ref, 'Uncapitalize') ? C.UncapitalizeDeferred(parameters[0]) :
|
|
35
|
+
Guard.IsEqual(ref, 'Uppercase') ? C.UppercaseDeferred(parameters[0]) :
|
|
36
|
+
T.CallConstruct(T.Ref(ref), parameters));
|
|
38
37
|
// deno-coverage-ignore-stop
|
|
39
38
|
}
|
|
40
39
|
// ------------------------------------------------------------------
|
|
@@ -206,7 +205,7 @@ function FactorExtends(type, extend) {
|
|
|
206
205
|
function FactorWith(type, withClause) {
|
|
207
206
|
return Guard.IsArray(withClause) && Guard.IsEqual(withClause.length, 0)
|
|
208
207
|
? type
|
|
209
|
-
: C.
|
|
208
|
+
: C.WithDeferred(type, withClause);
|
|
210
209
|
}
|
|
211
210
|
export function FactorMapping(input) {
|
|
212
211
|
const [keyOf, type, indexArray, extend, withClause] = input;
|
|
@@ -413,12 +412,13 @@ export function MappedMapping(input) {
|
|
|
413
412
|
? C.MappedDeferred(T.Identifier(input[3]), input[5], input[6][0], ApplyReadonly(input[1], ApplyOptional(input[8], input[10])))
|
|
414
413
|
: C.MappedDeferred(T.Identifier(input[3]), input[5], T.Ref(input[3]), ApplyReadonly(input[1], ApplyOptional(input[8], input[10]))));
|
|
415
414
|
}
|
|
415
|
+
export function DependentMapping(input) {
|
|
416
|
+
return (Guard.IsEqual(input.length, 6) ? T.Dependent(input[1], input[3], input[5]) :
|
|
417
|
+
T.Dependent(input[1], input[3], T.Unknown()));
|
|
418
|
+
}
|
|
416
419
|
export function ReferenceMapping(input) {
|
|
417
420
|
return T.Ref(input);
|
|
418
421
|
}
|
|
419
|
-
export function OptionsMapping(input) {
|
|
420
|
-
return C.OptionsDeferred(input[2], input[4]);
|
|
421
|
-
}
|
|
422
422
|
export function JsonNumberMapping(input) {
|
|
423
423
|
return parseFloat(input);
|
|
424
424
|
}
|
|
@@ -42,7 +42,7 @@ export type TKeyOf<Input extends string> = ((Token.TConst<'keyof', Input> extend
|
|
|
42
42
|
export type TIndexArray_0<Input extends string, Result extends unknown[] = []> = ((Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'[', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0, infer Input extends string] ? TIndexArray_0<Input, [...Result, _0]> : [Result, Input];
|
|
43
43
|
export type TIndexArray<Input extends string> = TIndexArray_0<Input> extends [infer _0 extends ([unknown, unknown, unknown] | [unknown, unknown])[], infer Input extends string] ? [S.TIndexArrayMapping<_0>, Input] : [];
|
|
44
44
|
export type TExtends<Input extends string> = ((Token.TConst<'extends', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExtendsMapping<_0>, Input] : [];
|
|
45
|
-
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : TKeyword<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Object_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTuple<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTemplateLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TConstructor<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Function_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TMapped<Input> extends [infer _0, infer Input extends string] ? [_0, Input] :
|
|
45
|
+
export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : TKeyword<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Object_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTuple<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTemplateLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TConstructor<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Function_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TMapped<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TDependent<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericCall<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TReference<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | unknown, infer Input extends string] ? [S.TBaseMapping<_0>, Input] : [];
|
|
46
46
|
export type TWith<Input extends string> = ((Token.TConst<'with', Input> extends [infer _0, infer Input extends string] ? (TJsonObject<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [], infer Input extends string] ? [S.TWithMapping<_0>, Input] : [];
|
|
47
47
|
export type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends<Input> extends [infer _3, infer Input extends string] ? (TWith<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TFactorMapping<_0>, Input] : [];
|
|
48
48
|
export type TExprTermTail<Input extends string> = ((Token.TConst<'&', Input> extends [infer _0, infer Input extends string] ? (TFactor<Input> extends [infer _1, infer Input extends string] ? (TExprTermTail<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExprTermTailMapping<_0>, Input] : [];
|
|
@@ -90,8 +90,8 @@ export type TMappedReadonly<Input extends string> = ((Token.TConst<'+', Input> e
|
|
|
90
90
|
export type TMappedOptional<Input extends string> = ((Token.TConst<'+', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'-', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'?', Input> extends [infer _0, infer Input extends string] ? [[_0], Input] : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [unknown] | [], infer Input extends string] ? [S.TMappedOptionalMapping<_0>, Input] : [];
|
|
91
91
|
export type TMappedAs<Input extends string> = ((Token.TConst<'as', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [], infer Input extends string] ? [S.TMappedAsMapping<_0>, Input] : [];
|
|
92
92
|
export type TMapped<Input extends string> = (Token.TConst<'{', Input> extends [infer _0, infer Input extends string] ? (TMappedReadonly<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'[', Input> extends [infer _2, infer Input extends string] ? (Token.TIdent<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'in', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? (TMappedAs<Input> extends [infer _6, infer Input extends string] ? (Token.TConst<']', Input> extends [infer _7, infer Input extends string] ? (TMappedOptional<Input> extends [infer _8, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _9, infer Input extends string] ? (TType<Input> extends [infer _10, infer Input extends string] ? (TOptionalSemiColon<Input> extends [infer _11, infer Input extends string] ? (Token.TConst<'}', Input> extends [infer _12, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], Input] : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TMappedMapping<_0>, Input] : [];
|
|
93
|
+
export type TDependent<Input extends string> = ((Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<'else', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : (Token.TConst<'if', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'then', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TDependentMapping<_0>, Input] : [];
|
|
93
94
|
export type TReference<Input extends string> = Token.TIdent<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TReferenceMapping<_0>, Input] : [];
|
|
94
|
-
export type TOptions<Input extends string> = (Token.TConst<'Options', Input> extends [infer _0, infer Input extends string] ? (Token.TConst<'<', Input> extends [infer _1, infer Input extends string] ? (TType<Input> extends [infer _2, infer Input extends string] ? (Token.TConst<',', Input> extends [infer _3, infer Input extends string] ? (TJsonObject<Input> extends [infer _4, infer Input extends string] ? (Token.TConst<'>', Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TOptionsMapping<_0>, Input] : [];
|
|
95
95
|
export type TJsonNumber<Input extends string> = Token.TNumber<Input> extends [infer _0 extends string, infer Input extends string] ? [S.TJsonNumberMapping<_0>, Input] : [];
|
|
96
96
|
export type TJsonBoolean<Input extends string> = (Token.TConst<'true', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : Token.TConst<'false', Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends 'true' | 'false', infer Input extends string] ? [S.TJsonBooleanMapping<_0>, Input] : [];
|
|
97
97
|
export type TJsonString<Input extends string> = Token.TString<['\"', '\''], Input> extends [infer _0 extends string, infer Input extends string] ? [S.TJsonStringMapping<_0>, Input] : [];
|
|
@@ -220,8 +220,8 @@ export declare const MappedReadonly: (input: string) => [unknown, string] | [];
|
|
|
220
220
|
export declare const MappedOptional: (input: string) => [unknown, string] | [];
|
|
221
221
|
export declare const MappedAs: (input: string) => [unknown, string] | [];
|
|
222
222
|
export declare const Mapped: (input: string) => [unknown, string] | [];
|
|
223
|
+
export declare const Dependent: (input: string) => [unknown, string] | [];
|
|
223
224
|
export declare const Reference: (input: string) => [unknown, string] | [];
|
|
224
|
-
export declare const Options: (input: string) => [unknown, string] | [];
|
|
225
225
|
export declare const JsonNumber: (input: string) => [unknown, string] | [];
|
|
226
226
|
export declare const JsonBoolean: (input: string) => [unknown, string] | [];
|
|
227
227
|
export declare const JsonString: (input: string) => [unknown, string] | [];
|
|
@@ -46,7 +46,7 @@ export const KeyOf = (input) => If(If(If(Token.Const('keyof', input), ([_0, inpu
|
|
|
46
46
|
export const IndexArray_0 = (input, result = []) => If(If(If(Token.Const('[', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(If(Token.Const('[', input), ([_0, input]) => If(Token.Const(']', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => IndexArray_0(input, [...result, _0]), () => [result, input]);
|
|
47
47
|
export const IndexArray = (input) => If(IndexArray_0(input), ([_0, input]) => [S.IndexArrayMapping(_0), input]);
|
|
48
48
|
export const Extends = (input) => If(If(If(Token.Const('extends', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('?', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const(':', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExtendsMapping(_0), input]);
|
|
49
|
-
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(Keyword(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(Tuple(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Literal(input), ([_0, input]) => [_0, input], () => If(Constructor(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(Mapped(input), ([_0, input]) => [_0, input], () => If(
|
|
49
|
+
export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(Keyword(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(Tuple(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Literal(input), ([_0, input]) => [_0, input], () => If(Constructor(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(Mapped(input), ([_0, input]) => [_0, input], () => If(Dependent(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))), ([_0, input]) => [S.BaseMapping(_0), input]);
|
|
50
50
|
export const With = (input) => If(If(If(Token.Const('with', input), ([_0, input]) => If(JsonObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithMapping(_0), input]);
|
|
51
51
|
export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => If(With(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.FactorMapping(_0), input]);
|
|
52
52
|
export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, input]) => If(Factor(input), ([_1, input]) => If(ExprTermTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTermTailMapping(_0), input]);
|
|
@@ -94,8 +94,8 @@ export const MappedReadonly = (input) => If(If(If(Token.Const('+', input), ([_0,
|
|
|
94
94
|
export const MappedOptional = (input) => If(If(If(Token.Const('+', input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('-', input), ([_0, input]) => If(Token.Const('?', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If(If(Token.Const('?', input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])))), ([_0, input]) => [S.MappedOptionalMapping(_0), input]);
|
|
95
95
|
export const MappedAs = (input) => If(If(If(Token.Const('as', input), ([_0, input]) => If(Type(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.MappedAsMapping(_0), input]);
|
|
96
96
|
export const Mapped = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(MappedReadonly(input), ([_1, input]) => If(Token.Const('[', input), ([_2, input]) => If(Token.Ident(input), ([_3, input]) => If(Token.Const('in', input), ([_4, input]) => If(Type(input), ([_5, input]) => If(MappedAs(input), ([_6, input]) => If(Token.Const(']', input), ([_7, input]) => If(MappedOptional(input), ([_8, input]) => If(Token.Const(':', input), ([_9, input]) => If(Type(input), ([_10, input]) => If(OptionalSemiColon(input), ([_11, input]) => If(Token.Const('}', input), ([_12, input]) => [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], input]))))))))))))), ([_0, input]) => [S.MappedMapping(_0), input]);
|
|
97
|
+
export const Dependent = (input) => If(If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const('else', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If(If(Token.Const('if', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('then', input), ([_2, input]) => If(Type(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.DependentMapping(_0), input]);
|
|
97
98
|
export const Reference = (input) => If(Token.Ident(input), ([_0, input]) => [S.ReferenceMapping(_0), input]);
|
|
98
|
-
export const Options = (input) => If(If(Token.Const('Options', input), ([_0, input]) => If(Token.Const('<', input), ([_1, input]) => If(Type(input), ([_2, input]) => If(Token.Const(',', input), ([_3, input]) => If(JsonObject(input), ([_4, input]) => If(Token.Const('>', input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [S.OptionsMapping(_0), input]);
|
|
99
99
|
export const JsonNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.JsonNumberMapping(_0), input]);
|
|
100
100
|
export const JsonBoolean = (input) => If(If(Token.Const('true', input), ([_0, input]) => [_0, input], () => If(Token.Const('false', input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.JsonBooleanMapping(_0), input]);
|
|
101
101
|
export const JsonString = (input) => If(Token.String(['\"', '\''], input), ([_0, input]) => [S.JsonStringMapping(_0), input]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type StaticType, type StaticDirection } from './static.mjs';
|
|
2
|
+
import { type TSchema, type TSchemaOptions } from './schema.mjs';
|
|
3
|
+
import { type TProperties } from './properties.mjs';
|
|
4
|
+
export type StaticDependent<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, If extends TSchema, Then extends TSchema, Else extends TSchema, StaticIf extends unknown = StaticType<Stack, Direction, Context, This, If>, StaticThen extends unknown = StaticType<Stack, Direction, Context, This, Then>, StaticElse extends unknown = StaticType<Stack, Direction, Context, This, Else>, Result extends unknown = (StaticIf & StaticThen) | Exclude<StaticElse, StaticIf>> = Result;
|
|
5
|
+
/** Represents a Dependent Type */
|
|
6
|
+
export interface TDependent<If extends TSchema = TSchema, Then extends TSchema = TSchema, Else extends TSchema = TSchema> extends TSchema {
|
|
7
|
+
'~kind': 'Dependent';
|
|
8
|
+
if: If;
|
|
9
|
+
then: Then;
|
|
10
|
+
else: Else;
|
|
11
|
+
}
|
|
12
|
+
/** Creates a Dependent type */
|
|
13
|
+
export declare function Dependent<If extends TSchema, Then extends TSchema, Else extends TSchema>(if_: If, then_: Then, else_: Else, options?: TSchemaOptions): TDependent<If, Then, Else>;
|
|
14
|
+
/** Returns true if the given value is TDependent. */
|
|
15
|
+
export declare function IsDependent(value: unknown): value is TDependent;
|
|
16
|
+
/** Extracts options from a IsDependent. */
|
|
17
|
+
export declare function DependentOptions(type: TDependent): TSchemaOptions;
|