@sinclair/typebox 0.34.25 → 0.34.27
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/cjs/parser/runtime/guard.d.ts +12 -6
- package/build/cjs/parser/runtime/guard.js +31 -20
- package/build/cjs/parser/runtime/module.d.ts +2 -2
- package/build/cjs/parser/runtime/module.js +4 -4
- package/build/cjs/parser/runtime/parse.d.ts +8 -8
- package/build/cjs/parser/runtime/parse.js +71 -43
- package/build/cjs/parser/runtime/types.d.ts +56 -26
- package/build/cjs/parser/runtime/types.js +34 -8
- package/build/cjs/parser/static/parse.d.ts +6 -3
- package/build/cjs/parser/static/types.d.ts +41 -18
- package/build/cjs/syntax/runtime.d.ts +2 -2
- package/build/cjs/syntax/runtime.js +13 -9
- package/build/cjs/syntax/static.d.ts +8 -5
- package/build/cjs/syntax/syntax.d.ts +2 -4
- package/build/cjs/syntax/syntax.js +1 -8
- package/build/cjs/type/module/compute.d.ts +16 -14
- package/build/cjs/type/module/compute.js +51 -40
- package/build/cjs/type/static/static.d.ts +14 -10
- package/build/cjs/value/transform/decode.js +3 -5
- package/build/cjs/value/transform/encode.js +3 -5
- package/build/cjs/value/transform/has.js +8 -0
- package/build/esm/parser/runtime/guard.d.mts +12 -6
- package/build/esm/parser/runtime/guard.mjs +26 -18
- package/build/esm/parser/runtime/module.d.mts +2 -2
- package/build/esm/parser/runtime/module.mjs +4 -4
- package/build/esm/parser/runtime/parse.d.mts +8 -8
- package/build/esm/parser/runtime/parse.mjs +71 -43
- package/build/esm/parser/runtime/types.d.mts +56 -26
- package/build/esm/parser/runtime/types.mjs +29 -6
- package/build/esm/parser/static/parse.d.mts +6 -3
- package/build/esm/parser/static/types.d.mts +41 -18
- package/build/esm/syntax/runtime.d.mts +2 -2
- package/build/esm/syntax/runtime.mjs +13 -9
- package/build/esm/syntax/static.d.mts +8 -5
- package/build/esm/syntax/syntax.d.mts +2 -4
- package/build/esm/syntax/syntax.mjs +1 -8
- package/build/esm/type/module/compute.d.mts +16 -14
- package/build/esm/type/module/compute.mjs +52 -41
- package/build/esm/type/static/static.d.mts +14 -10
- package/build/esm/value/transform/decode.mjs +3 -5
- package/build/esm/value/transform/encode.mjs +3 -5
- package/build/esm/value/transform/has.mjs +8 -0
- package/package.json +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `[ACTION]` Inference mapping base type. Used to specify semantic actions for
|
|
3
|
+
* Parser productions. This type is implemented as a higher-kinded type where
|
|
4
|
+
* productions are received on the `input` property with mapping assigned
|
|
5
|
+
* the `output` property. The parsing context is available on the `context`
|
|
6
|
+
* property.
|
|
7
|
+
*/
|
|
1
8
|
export interface IMapping {
|
|
2
9
|
context: unknown;
|
|
3
10
|
input: unknown;
|
|
4
11
|
output: unknown;
|
|
5
12
|
}
|
|
6
|
-
/**
|
|
13
|
+
/** `[ACTION]` Default inference mapping. */
|
|
7
14
|
export interface Identity extends IMapping {
|
|
8
15
|
output: this['input'];
|
|
9
16
|
}
|
|
10
|
-
/** Maps the
|
|
17
|
+
/** `[ACTION]` Maps the given argument `T` as the mapping output */
|
|
11
18
|
export interface As<T> extends IMapping {
|
|
12
19
|
output: T;
|
|
13
20
|
}
|
|
@@ -16,31 +23,47 @@ export interface IParser<Mapping extends IMapping = Identity> {
|
|
|
16
23
|
type: string;
|
|
17
24
|
mapping: Mapping;
|
|
18
25
|
}
|
|
19
|
-
/** Creates a
|
|
20
|
-
export interface
|
|
21
|
-
type: '
|
|
22
|
-
|
|
26
|
+
/** `[Context]` Creates a Context Parser */
|
|
27
|
+
export interface Context<Left extends IParser = IParser, Right extends IParser = IParser, Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
28
|
+
type: 'Context';
|
|
29
|
+
left: Left;
|
|
30
|
+
right: Right;
|
|
23
31
|
}
|
|
24
|
-
/** Creates
|
|
25
|
-
export interface
|
|
26
|
-
type: '
|
|
27
|
-
|
|
32
|
+
/** `[EBNF]` Creates an Array Parser */
|
|
33
|
+
export interface Array<Parser extends IParser = IParser, Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
34
|
+
type: 'Array';
|
|
35
|
+
parser: Parser;
|
|
28
36
|
}
|
|
29
|
-
/** Creates a Const Parser */
|
|
37
|
+
/** `[TERM]` Creates a Const Parser */
|
|
30
38
|
export interface Const<Value extends string = string, Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
31
39
|
type: 'Const';
|
|
32
40
|
value: Value;
|
|
33
41
|
}
|
|
34
|
-
/** Creates
|
|
35
|
-
export interface String<Options extends string[], Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
36
|
-
type: 'String';
|
|
37
|
-
quote: Options;
|
|
38
|
-
}
|
|
39
|
-
/** Creates an Ident Parser. */
|
|
42
|
+
/** `[TERM]` Creates an Ident Parser. */
|
|
40
43
|
export interface Ident<Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
41
44
|
type: 'Ident';
|
|
42
45
|
}
|
|
43
|
-
/** Creates a Number Parser. */
|
|
46
|
+
/** `[TERM]` Creates a Number Parser. */
|
|
44
47
|
export interface Number<Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
45
48
|
type: 'Number';
|
|
46
49
|
}
|
|
50
|
+
/** `[EBNF]` Creates a Optional Parser */
|
|
51
|
+
export interface Optional<Parser extends IParser = IParser, Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
52
|
+
type: 'Optional';
|
|
53
|
+
parser: Parser;
|
|
54
|
+
}
|
|
55
|
+
/** `[TERM]` Creates a String Parser. Options are an array of permissable quote characters */
|
|
56
|
+
export interface String<Options extends string[], Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
57
|
+
type: 'String';
|
|
58
|
+
quote: Options;
|
|
59
|
+
}
|
|
60
|
+
/** `[BNF]` Creates a Tuple Parser */
|
|
61
|
+
export interface Tuple<Parsers extends IParser[] = [], Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
62
|
+
type: 'Tuple';
|
|
63
|
+
parsers: [...Parsers];
|
|
64
|
+
}
|
|
65
|
+
/** `[BNF]` Creates a Union Parser */
|
|
66
|
+
export interface Union<Parsers extends IParser[] = [], Mapping extends IMapping = Identity> extends IParser<Mapping> {
|
|
67
|
+
type: 'Union';
|
|
68
|
+
parsers: [...Parsers];
|
|
69
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Runtime } from '../parser/index';
|
|
|
2
2
|
import * as t from '../type/index';
|
|
3
3
|
export declare const Module: Runtime.Module<{
|
|
4
4
|
GenericArgumentList: Runtime.IUnion<unknown[]>;
|
|
5
|
-
GenericArguments: Runtime.ITuple<
|
|
5
|
+
GenericArguments: Runtime.ITuple<t.TProperties>;
|
|
6
6
|
Literal: Runtime.IUnion<t.TLiteral<string> | t.TLiteral<number> | t.TLiteral<boolean>>;
|
|
7
7
|
Keyword: Runtime.IUnion<t.TAny | t.TBoolean | t.TBigInt | t.TNever | t.TString | t.TNumber | t.TInteger | t.TNull | t.TSymbol | t.TUndefined | t.TUnknown | t.TVoid>;
|
|
8
8
|
KeyOf: Runtime.IUnion<boolean>;
|
|
@@ -14,7 +14,7 @@ export declare const Module: Runtime.Module<{
|
|
|
14
14
|
ExprTerm: Runtime.ITuple<t.TSchema>;
|
|
15
15
|
ExprTail: Runtime.IUnion<[] | ["|", unknown, unknown]>;
|
|
16
16
|
Expr: Runtime.ITuple<t.TSchema>;
|
|
17
|
-
Type: Runtime.
|
|
17
|
+
Type: Runtime.IUnion<unknown>;
|
|
18
18
|
PropertyKey: Runtime.IUnion<string>;
|
|
19
19
|
Readonly: Runtime.IUnion<boolean>;
|
|
20
20
|
Optional: Runtime.IUnion<boolean>;
|
|
@@ -60,15 +60,15 @@ const GenericArgumentList = index_1.Runtime.Union([
|
|
|
60
60
|
// GenericArguments
|
|
61
61
|
// ------------------------------------------------------------------
|
|
62
62
|
// prettier-ignore
|
|
63
|
-
const GenericArgumentsContext = (args) => {
|
|
63
|
+
const GenericArgumentsContext = (args, context) => {
|
|
64
64
|
return args.reduce((result, arg, index) => {
|
|
65
65
|
return { ...result, [arg]: t.Argument(index) };
|
|
66
|
-
},
|
|
66
|
+
}, context);
|
|
67
67
|
};
|
|
68
68
|
// prettier-ignore
|
|
69
|
-
const GenericArgumentsMapping = (results) => {
|
|
69
|
+
const GenericArgumentsMapping = (results, context) => {
|
|
70
70
|
return results.length === 3
|
|
71
|
-
? GenericArgumentsContext(results[1])
|
|
71
|
+
? GenericArgumentsContext(results[1], context)
|
|
72
72
|
: {};
|
|
73
73
|
};
|
|
74
74
|
// prettier-ignore
|
|
@@ -76,7 +76,7 @@ const GenericArguments = index_1.Runtime.Tuple([
|
|
|
76
76
|
index_1.Runtime.Const(LAngle),
|
|
77
77
|
index_1.Runtime.Ref('GenericArgumentList'),
|
|
78
78
|
index_1.Runtime.Const(RAngle),
|
|
79
|
-
], results => GenericArgumentsMapping(results));
|
|
79
|
+
], (results, context) => GenericArgumentsMapping(results, context));
|
|
80
80
|
// ------------------------------------------------------------------
|
|
81
81
|
// GenericReference
|
|
82
82
|
// ------------------------------------------------------------------
|
|
@@ -286,7 +286,11 @@ const Expr = index_1.Runtime.Tuple([
|
|
|
286
286
|
// ------------------------------------------------------------------
|
|
287
287
|
// Type
|
|
288
288
|
// ------------------------------------------------------------------
|
|
289
|
-
|
|
289
|
+
// prettier-ignore
|
|
290
|
+
const Type = index_1.Runtime.Union([
|
|
291
|
+
index_1.Runtime.Context(index_1.Runtime.Ref('GenericArguments'), index_1.Runtime.Ref('Expr')),
|
|
292
|
+
index_1.Runtime.Ref('Expr')
|
|
293
|
+
]);
|
|
290
294
|
// ------------------------------------------------------------------
|
|
291
295
|
// Properties
|
|
292
296
|
// ------------------------------------------------------------------
|
|
@@ -653,12 +657,12 @@ const Uint8Array = index_1.Runtime.Const('Uint8Array', index_1.Runtime.As(t.Uint
|
|
|
653
657
|
// prettier-ignore
|
|
654
658
|
exports.Module = new index_1.Runtime.Module({
|
|
655
659
|
// ----------------------------------------------------------------
|
|
656
|
-
//
|
|
660
|
+
// Generics
|
|
657
661
|
// ----------------------------------------------------------------
|
|
658
662
|
GenericArgumentList,
|
|
659
663
|
GenericArguments,
|
|
660
664
|
// ----------------------------------------------------------------
|
|
661
|
-
// Type
|
|
665
|
+
// Type
|
|
662
666
|
// ----------------------------------------------------------------
|
|
663
667
|
Literal,
|
|
664
668
|
Keyword,
|
|
@@ -671,7 +675,7 @@ exports.Module = new index_1.Runtime.Module({
|
|
|
671
675
|
ExprTerm,
|
|
672
676
|
ExprTail,
|
|
673
677
|
Expr,
|
|
674
|
-
Type,
|
|
678
|
+
Type,
|
|
675
679
|
PropertyKey,
|
|
676
680
|
Readonly,
|
|
677
681
|
Optional,
|
|
@@ -52,13 +52,13 @@ type GenericArgumentList = Static.Union<[
|
|
|
52
52
|
Static.Tuple<[Static.Ident]>,
|
|
53
53
|
Static.Tuple<[]>
|
|
54
54
|
], GenericArgumentListMapping>;
|
|
55
|
-
type GenericArgumentsContext<Args extends string[], Result extends t.TProperties = {}> = (Args extends [...infer Left extends string[], infer Right extends string] ? GenericArgumentsContext<Left, Result & {
|
|
55
|
+
type GenericArgumentsContext<Args extends string[], Context extends t.TProperties, Result extends t.TProperties = {}> = (Args extends [...infer Left extends string[], infer Right extends string] ? GenericArgumentsContext<Left, Context, Result & {
|
|
56
56
|
[_ in Right]: t.TArgument<Left['length']>;
|
|
57
|
-
}> : t.Evaluate<Result>);
|
|
57
|
+
}> : t.Evaluate<Result & Context>);
|
|
58
58
|
interface GenericArgumentsMapping extends Static.IMapping {
|
|
59
|
-
output: this['input'] extends [LAngle, infer Args extends string[], RAngle] ? GenericArgumentsContext<Args> : never;
|
|
59
|
+
output: this['input'] extends [LAngle, infer Args extends string[], RAngle] ? this['context'] extends infer Context extends t.TProperties ? GenericArgumentsContext<Args, Context> : never : never;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
type GenericArguments = Static.Tuple<[
|
|
62
62
|
Static.Const<LAngle>,
|
|
63
63
|
GenericArgumentList,
|
|
64
64
|
Static.Const<RAngle>
|
|
@@ -204,7 +204,10 @@ type Expr = Static.Tuple<[
|
|
|
204
204
|
ExprTerm,
|
|
205
205
|
ExprTail
|
|
206
206
|
], ExprBinaryMapping>;
|
|
207
|
-
export type Type =
|
|
207
|
+
export type Type = Static.Union<[
|
|
208
|
+
Static.Context<GenericArguments, Expr>,
|
|
209
|
+
Expr
|
|
210
|
+
]>;
|
|
208
211
|
interface PropertyKeyStringMapping extends Static.IMapping {
|
|
209
212
|
output: this['input'];
|
|
210
213
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as t from '../type/index';
|
|
2
2
|
import { Static } from '../parser/index';
|
|
3
|
-
import { Type
|
|
4
|
-
type TParseSyntax<Context extends Record<PropertyKey, t.TSchema>, Code extends string> = (Static.Parse<GenericArguments, Code, {}> extends [infer Args extends t.TProperties, infer Rest extends string] ? Static.Parse<Type, Rest, Context & Args> : Static.Parse<Type, Code, Context>);
|
|
3
|
+
import { Type } from './static';
|
|
5
4
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type but does not infer schematics */
|
|
6
5
|
export declare function NoInfer<Context extends Record<PropertyKey, t.TSchema>, Code extends string>(context: Context, code: Code, options?: t.SchemaOptions): t.TSchema;
|
|
7
6
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type but does not infer schematics */
|
|
8
7
|
export declare function NoInfer<Code extends string>(code: Code, options?: t.SchemaOptions): t.TSchema;
|
|
9
8
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type */
|
|
10
|
-
export type TSyntax<Context extends Record<PropertyKey, t.TSchema>, Code extends string> = (
|
|
9
|
+
export type TSyntax<Context extends Record<PropertyKey, t.TSchema>, Code extends string> = (Static.Parse<Type, Code, Context> extends [infer Type extends t.TSchema, string] ? Type : t.TNever);
|
|
11
10
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type */
|
|
12
11
|
export declare function Syntax<Context extends Record<PropertyKey, t.TSchema>, Annotation extends string>(context: Context, annotation: Annotation, options?: t.SchemaOptions): TSyntax<Context, Annotation>;
|
|
13
12
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type */
|
|
@@ -28,4 +27,3 @@ export declare function ParseOnly<Context extends Record<PropertyKey, t.TSchema>
|
|
|
28
27
|
* @deprecated Use NoInfer() function
|
|
29
28
|
*/
|
|
30
29
|
export declare function ParseOnly<Code extends string>(code: Code, options?: t.SchemaOptions): t.TSchema | undefined;
|
|
31
|
-
export {};
|
|
@@ -7,19 +7,12 @@ exports.Parse = Parse;
|
|
|
7
7
|
exports.ParseOnly = ParseOnly;
|
|
8
8
|
const t = require("../type/index");
|
|
9
9
|
const runtime_1 = require("./runtime");
|
|
10
|
-
// prettier-ignore
|
|
11
|
-
function ParseSyntax(context, code) {
|
|
12
|
-
const results = runtime_1.Module.Parse('GenericArguments', code, {}); // [ArgumentContext, Rest]
|
|
13
|
-
return (results.length === 2
|
|
14
|
-
? runtime_1.Module.Parse('Type', results[1], { ...context, ...results[0] })
|
|
15
|
-
: runtime_1.Module.Parse('Type', code, context));
|
|
16
|
-
}
|
|
17
10
|
/** `[Experimental]` Parses a TypeScript annotation into a TypeBox type but does not infer schematics */
|
|
18
11
|
// prettier-ignore
|
|
19
12
|
function NoInfer(...args) {
|
|
20
13
|
const withContext = typeof args[0] === 'string' ? false : true;
|
|
21
14
|
const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}];
|
|
22
|
-
const result =
|
|
15
|
+
const result = runtime_1.Module.Parse('Type', code, context)[0];
|
|
23
16
|
return t.KindGuard.IsSchema(result)
|
|
24
17
|
? t.CloneType(result, options)
|
|
25
18
|
: t.Never(options);
|
|
@@ -20,11 +20,12 @@ import { TPartial } from '../partial/index';
|
|
|
20
20
|
import { type TReadonly } from '../readonly/index';
|
|
21
21
|
import { type TRecordOrObject, type TRecord } from '../record/index';
|
|
22
22
|
import { type TRef } from '../ref/index';
|
|
23
|
-
import { TRequired } from '../required/index';
|
|
23
|
+
import { type TRequired } from '../required/index';
|
|
24
|
+
import { type TTransform } from '../transform/index';
|
|
24
25
|
import { type TTuple } from '../tuple/index';
|
|
25
26
|
import { type TUnion, type TUnionEvaluated } from '../union/index';
|
|
26
|
-
type
|
|
27
|
-
type
|
|
27
|
+
type TDereferenceParameters<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef<infer Key extends string> ? TDereferenceParameters<ModuleProperties, Right, [...Result, TDereference<ModuleProperties, Key>]> : TDereferenceParameters<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
|
|
28
|
+
type TDereference<ModuleProperties extends TProperties, Ref extends string, Result extends TSchema = (Ref extends keyof ModuleProperties ? ModuleProperties[Ref] extends TRef<infer Ref2 extends string> ? TDereference<ModuleProperties, Ref2> : TFromType<ModuleProperties, ModuleProperties[Ref]> : TNever)> = Result;
|
|
28
29
|
type TFromAwaited<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TAwaited<T0> : never);
|
|
29
30
|
type TFromIndex<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TIndex<T0, TIndexPropertyKeys<T1>> extends infer Result extends TSchema ? Result : never : never);
|
|
30
31
|
type TFromKeyOf<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TKeyOf<T0> : never);
|
|
@@ -32,21 +33,22 @@ type TFromPartial<Parameters extends TSchema[]> = (Parameters extends [infer T0
|
|
|
32
33
|
type TFromOmit<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TOmit<T0, T1> : never);
|
|
33
34
|
type TFromPick<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TPick<T0, T1> : never);
|
|
34
35
|
type TFromRequired<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TRequired<T0> : never);
|
|
35
|
-
type TFromComputed<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] =
|
|
36
|
+
type TFromComputed<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] = TDereferenceParameters<ModuleProperties, Parameters>> = (Target extends 'Awaited' ? TFromAwaited<Dereferenced> : Target extends 'Index' ? TFromIndex<Dereferenced> : Target extends 'KeyOf' ? TFromKeyOf<Dereferenced> : Target extends 'Partial' ? TFromPartial<Dereferenced> : Target extends 'Omit' ? TFromOmit<Dereferenced> : Target extends 'Pick' ? TFromPick<Dereferenced> : Target extends 'Required' ? TFromRequired<Dereferenced> : TNever);
|
|
37
|
+
type TFromArray<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<TArray<TFromType<ModuleProperties, Type>>>);
|
|
38
|
+
type TFromAsyncIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TAsyncIterator<TFromType<ModuleProperties, Type>>);
|
|
39
|
+
type TFromConstructor<ModuleProperties extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema> = (TConstructor<TFromTypes<ModuleProperties, Parameters>, TFromType<ModuleProperties, InstanceType>>);
|
|
40
|
+
type TFromFunction<ModuleProperties extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema> = Ensure<Ensure<TFunction<TFromTypes<ModuleProperties, Parameters>, TFromType<ModuleProperties, ReturnType>>>>;
|
|
41
|
+
type TFromIntersect<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TIntersectEvaluated<TFromTypes<ModuleProperties, Types>>>);
|
|
42
|
+
type TFromIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TIterator<TFromType<ModuleProperties, Type>>);
|
|
36
43
|
type TFromObject<ModuleProperties extends TProperties, Properties extends TProperties> = Ensure<TObject<Evaluate<{
|
|
37
44
|
[Key in keyof Properties]: TFromType<ModuleProperties, Properties[Key]>;
|
|
38
45
|
}>>>;
|
|
39
46
|
type TFromRecord<ModuleProperties extends TProperties, Key extends TSchema, Value extends TSchema, Result extends TSchema = TRecordOrObject<Key, TFromType<ModuleProperties, Value>>> = Result;
|
|
40
|
-
type
|
|
41
|
-
type
|
|
42
|
-
type
|
|
43
|
-
type
|
|
44
|
-
type
|
|
45
|
-
type TFromArray<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<TArray<TFromType<ModuleProperties, Type>>>);
|
|
46
|
-
type TFromAsyncIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TAsyncIterator<TFromType<ModuleProperties, Type>>);
|
|
47
|
-
type TFromIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TIterator<TFromType<ModuleProperties, Type>>);
|
|
48
|
-
type TFromRest<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromRest<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
|
|
49
|
-
export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TFromType<ModuleProperties, Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TFromType<ModuleProperties, Type>> : Type extends TArray<infer Type extends TSchema> ? TFromArray<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator<ModuleProperties, Type> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<ModuleProperties, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<ModuleProperties, Properties> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TFromRecord<ModuleProperties, Key, Value> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Type : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<ModuleProperties, Types> : Type);
|
|
47
|
+
type TFromTransform<ModuleProperties extends TProperties, Input extends TSchema, Output extends unknown, Result extends TSchema = Input extends TRef<infer Key extends string> ? TTransform<TDereference<ModuleProperties, Key>, Output> : TTransform<Input, Output>> = Result;
|
|
48
|
+
type TFromTuple<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TTuple<TFromTypes<ModuleProperties, Types>>>);
|
|
49
|
+
type TFromUnion<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TUnionEvaluated<TFromTypes<ModuleProperties, Types>>>);
|
|
50
|
+
type TFromTypes<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromTypes<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
|
|
51
|
+
export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TFromType<ModuleProperties, Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TFromType<ModuleProperties, Type>> : Type extends TTransform<infer Input extends TSchema, infer Output extends unknown> ? TFromTransform<ModuleProperties, Input, Output> : Type extends TArray<infer Type extends TSchema> ? TFromArray<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator<ModuleProperties, Type> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<ModuleProperties, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<ModuleProperties, Properties> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TFromRecord<ModuleProperties, Key, Value> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Type : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<ModuleProperties, Types> : Type);
|
|
50
52
|
export declare function FromType<ModuleProperties extends TProperties, Type extends TSchema>(moduleProperties: ModuleProperties, type: Type): TFromType<ModuleProperties, Type>;
|
|
51
53
|
export type TComputeType<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TFromType<ModuleProperties, ModuleProperties[Key]> : TNever);
|
|
52
54
|
export declare function ComputeType<ModuleProperties extends TProperties, Key extends PropertyKey>(moduleProperties: ModuleProperties, key: Key): TComputeType<ModuleProperties, Key>;
|
|
@@ -25,24 +25,27 @@ const index_18 = require("../record/index");
|
|
|
25
25
|
const index_19 = require("../required/index");
|
|
26
26
|
const index_20 = require("../tuple/index");
|
|
27
27
|
const index_21 = require("../union/index");
|
|
28
|
+
// ------------------------------------------------------------------
|
|
29
|
+
// Symbols
|
|
30
|
+
// ------------------------------------------------------------------
|
|
28
31
|
const index_22 = require("../symbols/index");
|
|
29
32
|
// ------------------------------------------------------------------
|
|
30
33
|
// KindGuard
|
|
31
34
|
// ------------------------------------------------------------------
|
|
32
35
|
const KindGuard = require("../guard/kind");
|
|
33
36
|
// prettier-ignore
|
|
34
|
-
function
|
|
37
|
+
function DereferenceParameters(moduleProperties, types) {
|
|
35
38
|
return types.map((type) => {
|
|
36
39
|
return KindGuard.IsRef(type)
|
|
37
|
-
?
|
|
40
|
+
? Dereference(moduleProperties, type.$ref)
|
|
38
41
|
: FromType(moduleProperties, type);
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
// prettier-ignore
|
|
42
|
-
function
|
|
45
|
+
function Dereference(moduleProperties, ref) {
|
|
43
46
|
return (ref in moduleProperties
|
|
44
47
|
? KindGuard.IsRef(moduleProperties[ref])
|
|
45
|
-
?
|
|
48
|
+
? Dereference(moduleProperties, moduleProperties[ref].$ref)
|
|
46
49
|
: FromType(moduleProperties, moduleProperties[ref])
|
|
47
50
|
: (0, index_16.Never)());
|
|
48
51
|
}
|
|
@@ -76,7 +79,7 @@ function FromRequired(parameters) {
|
|
|
76
79
|
}
|
|
77
80
|
// prettier-ignore
|
|
78
81
|
function FromComputed(moduleProperties, target, parameters) {
|
|
79
|
-
const dereferenced =
|
|
82
|
+
const dereferenced = DereferenceParameters(moduleProperties, parameters);
|
|
80
83
|
return (target === 'Awaited' ? FromAwaited(dereferenced) :
|
|
81
84
|
target === 'Index' ? FromIndex(dereferenced) :
|
|
82
85
|
target === 'KeyOf' ? FromKeyOf(dereferenced) :
|
|
@@ -86,6 +89,26 @@ function FromComputed(moduleProperties, target, parameters) {
|
|
|
86
89
|
target === 'Required' ? FromRequired(dereferenced) :
|
|
87
90
|
(0, index_16.Never)());
|
|
88
91
|
}
|
|
92
|
+
function FromArray(moduleProperties, type) {
|
|
93
|
+
return (0, index_4.Array)(FromType(moduleProperties, type));
|
|
94
|
+
}
|
|
95
|
+
function FromAsyncIterator(moduleProperties, type) {
|
|
96
|
+
return (0, index_6.AsyncIterator)(FromType(moduleProperties, type));
|
|
97
|
+
}
|
|
98
|
+
// prettier-ignore
|
|
99
|
+
function FromConstructor(moduleProperties, parameters, instanceType) {
|
|
100
|
+
return (0, index_7.Constructor)(FromTypes(moduleProperties, parameters), FromType(moduleProperties, instanceType));
|
|
101
|
+
}
|
|
102
|
+
// prettier-ignore
|
|
103
|
+
function FromFunction(moduleProperties, parameters, returnType) {
|
|
104
|
+
return (0, index_9.Function)(FromTypes(moduleProperties, parameters), FromType(moduleProperties, returnType));
|
|
105
|
+
}
|
|
106
|
+
function FromIntersect(moduleProperties, types) {
|
|
107
|
+
return (0, index_10.Intersect)(FromTypes(moduleProperties, types));
|
|
108
|
+
}
|
|
109
|
+
function FromIterator(moduleProperties, type) {
|
|
110
|
+
return (0, index_11.Iterator)(FromType(moduleProperties, type));
|
|
111
|
+
}
|
|
89
112
|
function FromObject(moduleProperties, properties) {
|
|
90
113
|
return (0, index_13.Object)(globalThis.Object.keys(properties).reduce((result, key) => {
|
|
91
114
|
return { ...result, [key]: FromType(moduleProperties, properties[key]) };
|
|
@@ -99,53 +122,41 @@ function FromRecord(moduleProperties, type) {
|
|
|
99
122
|
return result;
|
|
100
123
|
}
|
|
101
124
|
// prettier-ignore
|
|
102
|
-
function
|
|
103
|
-
return (
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function FromFunction(moduleProperties, parameters, returnType) {
|
|
107
|
-
return (0, index_9.Function)(FromRest(moduleProperties, parameters), FromType(moduleProperties, returnType));
|
|
125
|
+
function FromTransform(moduleProperties, transform) {
|
|
126
|
+
return (KindGuard.IsRef(transform))
|
|
127
|
+
? { ...Dereference(moduleProperties, transform.$ref), [index_22.TransformKind]: transform[index_22.TransformKind] }
|
|
128
|
+
: transform;
|
|
108
129
|
}
|
|
109
130
|
function FromTuple(moduleProperties, types) {
|
|
110
|
-
return (0, index_20.Tuple)(
|
|
111
|
-
}
|
|
112
|
-
function FromIntersect(moduleProperties, types) {
|
|
113
|
-
return (0, index_10.Intersect)(FromRest(moduleProperties, types));
|
|
131
|
+
return (0, index_20.Tuple)(FromTypes(moduleProperties, types));
|
|
114
132
|
}
|
|
115
133
|
function FromUnion(moduleProperties, types) {
|
|
116
|
-
return (0, index_21.Union)(
|
|
117
|
-
}
|
|
118
|
-
function FromArray(moduleProperties, type) {
|
|
119
|
-
return (0, index_4.Array)(FromType(moduleProperties, type));
|
|
120
|
-
}
|
|
121
|
-
function FromAsyncIterator(moduleProperties, type) {
|
|
122
|
-
return (0, index_6.AsyncIterator)(FromType(moduleProperties, type));
|
|
123
|
-
}
|
|
124
|
-
function FromIterator(moduleProperties, type) {
|
|
125
|
-
return (0, index_11.Iterator)(FromType(moduleProperties, type));
|
|
134
|
+
return (0, index_21.Union)(FromTypes(moduleProperties, types));
|
|
126
135
|
}
|
|
127
|
-
function
|
|
136
|
+
function FromTypes(moduleProperties, types) {
|
|
128
137
|
return types.map((type) => FromType(moduleProperties, type));
|
|
129
138
|
}
|
|
130
139
|
// prettier-ignore
|
|
131
140
|
function FromType(moduleProperties, type) {
|
|
132
141
|
return (
|
|
133
|
-
//
|
|
142
|
+
// Modifiers
|
|
134
143
|
KindGuard.IsOptional(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_3.Discard)(type, [index_22.OptionalKind])), type) :
|
|
135
144
|
KindGuard.IsReadonly(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_3.Discard)(type, [index_22.ReadonlyKind])), type) :
|
|
136
|
-
//
|
|
137
|
-
KindGuard.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
// Transform
|
|
146
|
+
KindGuard.IsTransform(type) ? (0, index_1.CreateType)(FromTransform(moduleProperties, type), type) :
|
|
147
|
+
// Types
|
|
148
|
+
KindGuard.IsArray(type) ? (0, index_1.CreateType)(FromArray(moduleProperties, type.items), type) :
|
|
149
|
+
KindGuard.IsAsyncIterator(type) ? (0, index_1.CreateType)(FromAsyncIterator(moduleProperties, type.items), type) :
|
|
150
|
+
KindGuard.IsComputed(type) ? (0, index_1.CreateType)(FromComputed(moduleProperties, type.target, type.parameters)) :
|
|
151
|
+
KindGuard.IsConstructor(type) ? (0, index_1.CreateType)(FromConstructor(moduleProperties, type.parameters, type.returns), type) :
|
|
152
|
+
KindGuard.IsFunction(type) ? (0, index_1.CreateType)(FromFunction(moduleProperties, type.parameters, type.returns), type) :
|
|
153
|
+
KindGuard.IsIntersect(type) ? (0, index_1.CreateType)(FromIntersect(moduleProperties, type.allOf), type) :
|
|
154
|
+
KindGuard.IsIterator(type) ? (0, index_1.CreateType)(FromIterator(moduleProperties, type.items), type) :
|
|
155
|
+
KindGuard.IsObject(type) ? (0, index_1.CreateType)(FromObject(moduleProperties, type.properties), type) :
|
|
156
|
+
KindGuard.IsRecord(type) ? (0, index_1.CreateType)(FromRecord(moduleProperties, type)) :
|
|
157
|
+
KindGuard.IsTuple(type) ? (0, index_1.CreateType)(FromTuple(moduleProperties, type.items || []), type) :
|
|
158
|
+
KindGuard.IsUnion(type) ? (0, index_1.CreateType)(FromUnion(moduleProperties, type.anyOf), type) :
|
|
159
|
+
type);
|
|
149
160
|
}
|
|
150
161
|
// prettier-ignore
|
|
151
162
|
function ComputeType(moduleProperties, key) {
|
|
@@ -7,6 +7,7 @@ import type { TConstructor } from '../constructor/index';
|
|
|
7
7
|
import type { TEnum } from '../enum/index';
|
|
8
8
|
import type { TFunction } from '../function/index';
|
|
9
9
|
import type { TIntersect } from '../intersect/index';
|
|
10
|
+
import type { TImport } from '../module/index';
|
|
10
11
|
import type { TIterator } from '../iterator/index';
|
|
11
12
|
import type { TNot } from '../not/index';
|
|
12
13
|
import type { TObject, TProperties } from '../object/index';
|
|
@@ -19,17 +20,20 @@ import type { TUnion } from '../union/index';
|
|
|
19
20
|
import type { TUnsafe } from '../unsafe/index';
|
|
20
21
|
import type { TSchema } from '../schema/index';
|
|
21
22
|
import type { TTransform } from '../transform/index';
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
import type { TNever } from '../never/index';
|
|
24
|
+
type TDecodeImport<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TDecodeType<ModuleProperties[Key]> extends infer Type extends TSchema ? Type extends TRef<infer Ref extends string> ? TDecodeImport<ModuleProperties, Ref> : Type : TNever : TNever);
|
|
25
|
+
type TDecodeProperties<Properties extends TProperties> = {
|
|
26
|
+
[Key in keyof Properties]: TDecodeType<Properties[Key]>;
|
|
24
27
|
};
|
|
25
|
-
|
|
26
|
-
export type TDecodeType<
|
|
27
|
-
export type StaticDecodeIsAny<
|
|
28
|
+
type TDecodeTypes<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TDecodeTypes<Right, [...Result, TDecodeType<Left>]> : Result);
|
|
29
|
+
export type TDecodeType<Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TDecodeType<Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TDecodeType<Type>> : Type extends TTransform<infer _Input extends TSchema, infer Output> ? TUnsafe<Output> : Type extends TArray<infer Type extends TSchema> ? TArray<TDecodeType<Type>> : Type extends TAsyncIterator<infer Type extends TSchema> ? TAsyncIterator<TDecodeType<Type>> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TConstructor<TDecodeTypes<Parameters>, TDecodeType<InstanceType>> : Type extends TEnum<infer Values> ? TEnum<Values> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFunction<TDecodeTypes<Parameters>, TDecodeType<ReturnType>> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TDecodeTypes<Types>> : Type extends TImport<infer ModuleProperties extends TProperties, infer Key> ? TDecodeImport<ModuleProperties, Key> : Type extends TIterator<infer Type extends TSchema> ? TIterator<TDecodeType<Type>> : Type extends TNot<infer Type extends TSchema> ? TNot<TDecodeType<Type>> : Type extends TObject<infer Properties extends TProperties> ? TObject<Evaluate<TDecodeProperties<Properties>>> : Type extends TPromise<infer Type extends TSchema> ? TPromise<TDecodeType<Type>> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TRecord<Key, TDecodeType<Value>> : Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TDecodeType<Type>> : Type extends TRef<infer Ref extends string> ? TRef<Ref> : Type extends TTuple<infer Types extends TSchema[]> ? TTuple<TDecodeTypes<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TDecodeTypes<Types>> : Type);
|
|
30
|
+
export type StaticDecodeIsAny<Type> = boolean extends (Type extends TSchema ? true : false) ? true : false;
|
|
28
31
|
/** Creates an decoded static type from a TypeBox type */
|
|
29
|
-
export type StaticDecode<
|
|
32
|
+
export type StaticDecode<Type extends TSchema, Params extends unknown[] = [], Result = StaticDecodeIsAny<Type> extends true ? unknown : Static<TDecodeType<Type>, Params>> = Result;
|
|
30
33
|
/** Creates an encoded static type from a TypeBox type */
|
|
31
|
-
export type StaticEncode<
|
|
34
|
+
export type StaticEncode<Type extends TSchema, Params extends unknown[] = [], Result = Static<Type, Params>> = Result;
|
|
32
35
|
/** Creates a static type from a TypeBox type */
|
|
33
|
-
export type Static<
|
|
34
|
-
params:
|
|
35
|
-
})['static'];
|
|
36
|
+
export type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
|
|
37
|
+
params: Params;
|
|
38
|
+
})['static']> = Result;
|
|
39
|
+
export {};
|
|
@@ -85,12 +85,10 @@ function FromIntersect(schema, references, path, value) {
|
|
|
85
85
|
}
|
|
86
86
|
// prettier-ignore
|
|
87
87
|
function FromImport(schema, references, path, value) {
|
|
88
|
-
const
|
|
88
|
+
const additional = globalThis.Object.values(schema.$defs);
|
|
89
89
|
const target = schema.$defs[schema.$ref];
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const transformTarget = { [index_1.TransformKind]: transform, ...target };
|
|
93
|
-
return Visit(transformTarget, [...references, ...definitions], path, value);
|
|
90
|
+
const result = Visit(target, [...references, ...additional], path, value);
|
|
91
|
+
return Default(schema, path, result);
|
|
94
92
|
}
|
|
95
93
|
function FromNot(schema, references, path, value) {
|
|
96
94
|
return Default(schema, path, Visit(schema.not, references, path, value));
|
|
@@ -62,12 +62,10 @@ function FromArray(schema, references, path, value) {
|
|
|
62
62
|
}
|
|
63
63
|
// prettier-ignore
|
|
64
64
|
function FromImport(schema, references, path, value) {
|
|
65
|
-
const
|
|
65
|
+
const additional = globalThis.Object.values(schema.$defs);
|
|
66
66
|
const target = schema.$defs[schema.$ref];
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const transformTarget = { [index_1.TransformKind]: transform, ...target };
|
|
70
|
-
return Visit(transformTarget, [...references, ...definitions], path, value);
|
|
67
|
+
const result = Default(schema, path, value);
|
|
68
|
+
return Visit(target, [...references, ...additional], path, result);
|
|
71
69
|
}
|
|
72
70
|
// prettier-ignore
|
|
73
71
|
function FromIntersect(schema, references, path, value) {
|
|
@@ -33,6 +33,12 @@ function FromIntersect(schema, references) {
|
|
|
33
33
|
return (0, kind_1.IsTransform)(schema) || (0, kind_1.IsTransform)(schema.unevaluatedProperties) || schema.allOf.some((schema) => Visit(schema, references));
|
|
34
34
|
}
|
|
35
35
|
// prettier-ignore
|
|
36
|
+
function FromImport(schema, references) {
|
|
37
|
+
const additional = globalThis.Object.getOwnPropertyNames(schema.$defs).reduce((result, key) => [...result, schema.$defs[key]], []);
|
|
38
|
+
const target = schema.$defs[schema.$ref];
|
|
39
|
+
return (0, kind_1.IsTransform)(schema) || Visit(target, [...additional, ...references]);
|
|
40
|
+
}
|
|
41
|
+
// prettier-ignore
|
|
36
42
|
function FromIterator(schema, references) {
|
|
37
43
|
return (0, kind_1.IsTransform)(schema) || Visit(schema.items, references);
|
|
38
44
|
}
|
|
@@ -93,6 +99,8 @@ function Visit(schema, references) {
|
|
|
93
99
|
return FromConstructor(schema_, references_);
|
|
94
100
|
case 'Function':
|
|
95
101
|
return FromFunction(schema_, references_);
|
|
102
|
+
case 'Import':
|
|
103
|
+
return FromImport(schema_, references_);
|
|
96
104
|
case 'Intersect':
|
|
97
105
|
return FromIntersect(schema_, references_);
|
|
98
106
|
case 'Iterator':
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { IIdent, INumber, IRef, IString,
|
|
2
|
-
/** Returns true if the value is a
|
|
3
|
-
export declare function
|
|
4
|
-
/** Returns true if the value is a Union Parser */
|
|
5
|
-
export declare function IsUnion(value: unknown): value is IUnion;
|
|
1
|
+
import { IArray, IConst, IContext, IIdent, INumber, IOptional, IRef, IString, ITuple, IUnion } from './types.mjs';
|
|
2
|
+
/** Returns true if the value is a Array Parser */
|
|
3
|
+
export declare function IsArray(value: unknown): value is IArray;
|
|
6
4
|
/** Returns true if the value is a Const Parser */
|
|
7
5
|
export declare function IsConst(value: unknown): value is IConst;
|
|
6
|
+
/** Returns true if the value is a Context Parser */
|
|
7
|
+
export declare function IsContext(value: unknown): value is IContext;
|
|
8
8
|
/** Returns true if the value is a Ident Parser */
|
|
9
9
|
export declare function IsIdent(value: unknown): value is IIdent;
|
|
10
10
|
/** Returns true if the value is a Number Parser */
|
|
11
11
|
export declare function IsNumber(value: unknown): value is INumber;
|
|
12
|
+
/** Returns true if the value is a Optional Parser */
|
|
13
|
+
export declare function IsOptional(value: unknown): value is IOptional;
|
|
12
14
|
/** Returns true if the value is a Ref Parser */
|
|
13
15
|
export declare function IsRef(value: unknown): value is IRef;
|
|
14
16
|
/** Returns true if the value is a String Parser */
|
|
15
17
|
export declare function IsString(value: unknown): value is IString;
|
|
18
|
+
/** Returns true if the value is a Tuple Parser */
|
|
19
|
+
export declare function IsTuple(value: unknown): value is ITuple;
|
|
20
|
+
/** Returns true if the value is a Union Parser */
|
|
21
|
+
export declare function IsUnion(value: unknown): value is IUnion;
|
|
16
22
|
/** Returns true if the value is a Parser */
|
|
17
|
-
export declare function IsParser(value: unknown): value is IUnion<unknown> |
|
|
23
|
+
export declare function IsParser(value: unknown): value is IContext<unknown> | IUnion<unknown> | IArray<unknown> | IConst<unknown> | IIdent<unknown> | INumber<unknown> | IOptional<unknown> | IRef<unknown> | IString<unknown> | ITuple<unknown>;
|