@sinclair/typebox 0.34.15 → 0.34.17
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/compiler/compiler.js +5 -0
- package/build/cjs/errors/errors.js +3 -0
- package/build/cjs/index.d.ts +3 -0
- package/build/cjs/index.js +3 -0
- package/build/cjs/syntax/index.d.ts +1 -1
- package/build/cjs/syntax/index.js +1 -1
- package/build/cjs/syntax/runtime.d.ts +40 -54
- package/build/cjs/syntax/runtime.js +91 -203
- package/build/cjs/syntax/static.d.ts +80 -146
- package/build/cjs/syntax/syntax.d.ts +33 -0
- package/build/cjs/syntax/syntax.js +37 -0
- package/build/cjs/type/argument/argument.d.ts +9 -0
- package/build/cjs/type/argument/argument.js +10 -0
- package/build/cjs/type/argument/index.d.ts +1 -0
- package/build/cjs/type/argument/index.js +18 -0
- package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +3 -3
- package/build/cjs/type/constructor-parameters/constructor-parameters.js +3 -1
- package/build/cjs/type/guard/kind.d.ts +9 -6
- package/build/cjs/type/guard/kind.js +6 -0
- package/build/cjs/type/guard/type.d.ts +9 -6
- package/build/cjs/type/guard/type.js +9 -0
- package/build/cjs/type/index.d.ts +2 -0
- package/build/cjs/type/index.js +2 -0
- package/build/cjs/type/instance-type/instance-type.d.ts +5 -4
- package/build/cjs/type/instance-type/instance-type.js +3 -1
- package/build/cjs/type/instantiate/index.d.ts +1 -0
- package/build/cjs/type/instantiate/index.js +18 -0
- package/build/cjs/type/instantiate/instantiate.d.ts +25 -0
- package/build/cjs/type/instantiate/instantiate.js +32 -0
- package/build/cjs/type/parameters/parameters.d.ts +3 -3
- package/build/cjs/type/parameters/parameters.js +3 -1
- package/build/cjs/type/record/record.d.ts +16 -1
- package/build/cjs/type/record/record.js +53 -23
- package/build/cjs/type/remap/index.d.ts +1 -0
- package/build/cjs/type/remap/index.js +18 -0
- package/build/cjs/type/remap/remap.d.ts +19 -0
- package/build/cjs/type/remap/remap.js +35 -0
- package/build/cjs/type/return-type/return-type.d.ts +5 -4
- package/build/cjs/type/return-type/return-type.js +3 -1
- package/build/cjs/type/type/javascript.d.ts +10 -4
- package/build/cjs/type/type/javascript.js +44 -34
- package/build/cjs/type/type/type.d.ts +3 -0
- package/build/cjs/type/type/type.js +123 -117
- package/build/cjs/value/check/check.js +5 -0
- package/build/cjs/value/create/create.js +5 -0
- package/build/esm/compiler/compiler.mjs +5 -0
- package/build/esm/errors/errors.mjs +3 -0
- package/build/esm/index.d.mts +3 -0
- package/build/esm/index.mjs +3 -0
- package/build/esm/syntax/index.d.mts +1 -1
- package/build/esm/syntax/index.mjs +1 -1
- package/build/esm/syntax/runtime.d.mts +40 -54
- package/build/esm/syntax/runtime.mjs +91 -203
- package/build/esm/syntax/static.d.mts +80 -146
- package/build/esm/syntax/syntax.d.mts +33 -0
- package/build/esm/syntax/syntax.mjs +30 -0
- package/build/esm/type/argument/argument.d.mts +9 -0
- package/build/esm/type/argument/argument.mjs +6 -0
- package/build/esm/type/argument/index.d.mts +1 -0
- package/build/esm/type/argument/index.mjs +1 -0
- package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +3 -3
- package/build/esm/type/constructor-parameters/constructor-parameters.mjs +3 -1
- package/build/esm/type/guard/kind.d.mts +9 -6
- package/build/esm/type/guard/kind.mjs +5 -0
- package/build/esm/type/guard/type.d.mts +9 -6
- package/build/esm/type/guard/type.mjs +8 -0
- package/build/esm/type/index.d.mts +2 -0
- package/build/esm/type/index.mjs +2 -0
- package/build/esm/type/instance-type/instance-type.d.mts +5 -4
- package/build/esm/type/instance-type/instance-type.mjs +3 -1
- package/build/esm/type/instantiate/index.d.mts +1 -0
- package/build/esm/type/instantiate/index.mjs +1 -0
- package/build/esm/type/instantiate/instantiate.d.mts +25 -0
- package/build/esm/type/instantiate/instantiate.mjs +28 -0
- package/build/esm/type/parameters/parameters.d.mts +3 -3
- package/build/esm/type/parameters/parameters.mjs +3 -1
- package/build/esm/type/record/record.d.mts +16 -1
- package/build/esm/type/record/record.mjs +35 -8
- package/build/esm/type/remap/index.d.mts +1 -0
- package/build/esm/type/remap/index.mjs +1 -0
- package/build/esm/type/remap/remap.d.mts +19 -0
- package/build/esm/type/remap/remap.mjs +31 -0
- package/build/esm/type/return-type/return-type.d.mts +5 -4
- package/build/esm/type/return-type/return-type.mjs +3 -1
- package/build/esm/type/type/javascript.d.mts +10 -4
- package/build/esm/type/type/javascript.mjs +10 -0
- package/build/esm/type/type/type.d.mts +3 -0
- package/build/esm/type/type/type.mjs +3 -0
- package/build/esm/value/check/check.mjs +5 -0
- package/build/esm/value/create/create.mjs +5 -0
- package/package.json +11 -1
- package/parser/package.json +4 -0
- package/readme.md +107 -184
- package/build/cjs/syntax/parse.d.ts +0 -15
- package/build/cjs/syntax/parse.js +0 -19
- package/build/esm/syntax/parse.d.mts +0 -15
- package/build/esm/syntax/parse.mjs +0 -14
- /package/build/cjs/{syntax/parsebox → parser}/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/module.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/runtime/types.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/index.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/parse.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/token.js +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.d.ts +0 -0
- /package/build/cjs/{syntax/parsebox → parser}/static/types.js +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/guard.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/module.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/runtime/types.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/index.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/parse.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/token.mjs +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.d.mts +0 -0
- /package/build/esm/{syntax/parsebox → parser}/static/types.mjs +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Static } from '
|
|
2
|
-
import * as
|
|
1
|
+
import { Static } from '../parser/index';
|
|
2
|
+
import * as t from '../type/index';
|
|
3
3
|
type Newline = '\n';
|
|
4
4
|
type LBracket = '[';
|
|
5
5
|
type RBracket = ']';
|
|
@@ -16,7 +16,6 @@ type SemiColon = ';';
|
|
|
16
16
|
type SingleQuote = "'";
|
|
17
17
|
type DoubleQuote = '"';
|
|
18
18
|
type Tilde = '`';
|
|
19
|
-
type Equals = '=';
|
|
20
19
|
interface DelimitTailMapping<_ = unknown> extends Static.IMapping {
|
|
21
20
|
output: (this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer E, _, infer F, _, infer G, _, infer H, _, infer I, _, infer Rest extends unknown[]] ? [A, B, C, D, E, F, G, H, I, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer E, _, infer F, _, infer G, _, infer H, _, infer Rest extends unknown[]] ? [A, B, C, D, E, F, G, H, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer E, _, infer F, _, infer G, _, infer Rest extends unknown[]] ? [A, B, C, D, E, F, G, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer E, _, infer F, _, infer Rest extends unknown[]] ? [A, B, C, D, E, F, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer E, _, infer Rest extends unknown[]] ? [A, B, C, D, E, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer D, _, infer Rest extends unknown[]] ? [A, B, C, D, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer C, _, infer Rest extends unknown[]] ? [A, B, C, ...Rest] : this['input'] extends [_, infer A, _, infer B, _, infer Rest extends unknown[]] ? [A, B, ...Rest] : this['input'] extends [_, infer A, _, infer Rest extends unknown[]] ? [A, ...Rest] : this['input'] extends [_, infer Rest extends unknown[]] ? [...Rest] : this['input'] extends [_] ? [] : [
|
|
22
21
|
]);
|
|
@@ -42,98 +41,28 @@ type Delimit<Parser extends Static.IParser, Delimiter extends Static.IParser> =
|
|
|
42
41
|
Static.Tuple<[Parser, DelimitTail<Parser, Delimiter>]>,
|
|
43
42
|
Static.Tuple<[]>
|
|
44
43
|
], DelimitMapping>);
|
|
45
|
-
type
|
|
46
|
-
interface
|
|
47
|
-
output: this['input'] extends [string] ?
|
|
44
|
+
type Dereference<Context extends t.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : t.TRef<Ref>);
|
|
45
|
+
interface GenericReferenceMapping extends Static.IMapping {
|
|
46
|
+
output: this['context'] extends t.TProperties ? this['input'] extends [infer Reference extends string, LAngle, infer Parameters extends t.TSchema[], RAngle] ? t.TInstantiate<Dereference<this['context'], Reference>, [...Parameters]> : never : never;
|
|
48
47
|
}
|
|
49
|
-
type
|
|
50
|
-
Static.Tuple<[Static.Const<'export'>]>,
|
|
51
|
-
Static.Tuple<[]>
|
|
52
|
-
], ExportModifierMapping>;
|
|
53
|
-
interface TypeAliasDeclarationMapping extends Static.IMapping {
|
|
54
|
-
output: this['input'] extends [infer _Export extends boolean, 'type', infer Ident extends string, Equals, infer Type extends Types.TSchema] ? {
|
|
55
|
-
[_ in Ident]: Type;
|
|
56
|
-
} : never;
|
|
57
|
-
}
|
|
58
|
-
type TypeAliasDeclaration = Static.Tuple<[
|
|
59
|
-
ExportModifier,
|
|
60
|
-
Static.Const<'type'>,
|
|
61
|
-
Static.Ident,
|
|
62
|
-
Static.Const<Equals>,
|
|
63
|
-
Type
|
|
64
|
-
], TypeAliasDeclarationMapping>;
|
|
65
|
-
type HeritageListDelimiter = Static.Union<[Static.Tuple<[Static.Const<Comma>, Static.Const<Newline>]>, Static.Tuple<[Static.Const<Comma>]>]>;
|
|
66
|
-
type HeritageListReduce<Values extends string[], Context extends Types.TProperties, Result extends Types.TSchema[] = []> = (Values extends [infer Ref extends string, ...infer Rest extends string[]] ? HeritageListReduce<Rest, Context, [...Result, Deref<Context, Ref>]> : Result);
|
|
67
|
-
interface HeritageListMapping extends Static.IMapping {
|
|
68
|
-
output: (this['context'] extends Types.TProperties ? this['input'] extends string[] ? HeritageListReduce<this['input'], this['context']> : [] : []);
|
|
69
|
-
}
|
|
70
|
-
type HeritageList = Static.Union<[Delimit<Static.Ident, HeritageListDelimiter>], HeritageListMapping>;
|
|
71
|
-
interface HeritageMapping extends Static.IMapping {
|
|
72
|
-
output: this['input'] extends ['extends', infer List extends Types.TSchema[]] ? List : [];
|
|
73
|
-
}
|
|
74
|
-
type Heritage = Static.Union<[
|
|
75
|
-
Static.Tuple<[Static.Const<'extends'>, HeritageList]>,
|
|
76
|
-
Static.Tuple<[]>
|
|
77
|
-
], HeritageMapping>;
|
|
78
|
-
interface InterfaceDeclarationMapping extends Static.IMapping {
|
|
79
|
-
output: this['input'] extends [boolean, 'interface', infer Ident extends string, infer Heritage extends Types.TSchema[], LBrace, infer Properties extends Types.TProperties, RBrace] ? {
|
|
80
|
-
[_ in Ident]: Types.TIntersectEvaluated<[...Heritage, Types.TObject<Properties>]>;
|
|
81
|
-
} : never;
|
|
82
|
-
}
|
|
83
|
-
type InterfaceDeclaration = Static.Tuple<[
|
|
84
|
-
ExportModifier,
|
|
85
|
-
Static.Const<'interface'>,
|
|
48
|
+
type GenericReference = Static.Tuple<[
|
|
86
49
|
Static.Ident,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
], InterfaceDeclarationMapping>;
|
|
92
|
-
type ModuleType = Static.Union<[
|
|
93
|
-
InterfaceDeclaration,
|
|
94
|
-
TypeAliasDeclaration
|
|
95
|
-
]>;
|
|
96
|
-
type ModulePropertiesDelimiter = Static.Union<[
|
|
97
|
-
Static.Tuple<[Static.Const<SemiColon>, Static.Const<Newline>]>,
|
|
98
|
-
Static.Tuple<[Static.Const<SemiColon>]>,
|
|
99
|
-
Static.Tuple<[Static.Const<Newline>]>
|
|
100
|
-
]>;
|
|
101
|
-
type ModulePropertiesReduce<Value extends unknown[], Result extends Types.TProperties = {}> = (Value extends [infer ModuleType extends Types.TProperties, unknown[], ...infer Rest extends unknown[]] ? ModulePropertiesReduce<Rest, Result & ModuleType> : Value extends [infer ModuleType extends Types.TProperties] ? ModulePropertiesReduce<[], Result & ModuleType> : Types.Evaluate<Result>);
|
|
102
|
-
interface ModulePropertiesMapping extends Static.IMapping {
|
|
103
|
-
output: this['input'] extends unknown[] ? ModulePropertiesReduce<this['input']> : never;
|
|
104
|
-
}
|
|
105
|
-
type ModuleProperties = Static.Union<[
|
|
106
|
-
Static.Tuple<[ModuleType, ModulePropertiesDelimiter, ModuleProperties]>,
|
|
107
|
-
Static.Tuple<[ModuleType]>,
|
|
108
|
-
Static.Tuple<[]>
|
|
109
|
-
], ModulePropertiesMapping>;
|
|
110
|
-
type ModuleIdentifier = Static.Union<[
|
|
111
|
-
Static.Tuple<[Static.Ident]>,
|
|
112
|
-
Static.Tuple<[]>
|
|
113
|
-
]>;
|
|
114
|
-
interface ModuleDeclarationMapping extends Static.IMapping {
|
|
115
|
-
output: this['input'] extends [boolean, 'module', infer _Ident extends string[], LBrace, infer Properties extends Types.TProperties, RBrace] ? Types.TModule<Properties> : never;
|
|
116
|
-
}
|
|
117
|
-
type ModuleDeclaration = Static.Tuple<[
|
|
118
|
-
ExportModifier,
|
|
119
|
-
Static.Const<'module'>,
|
|
120
|
-
ModuleIdentifier,
|
|
121
|
-
Static.Const<LBrace>,
|
|
122
|
-
ModuleProperties,
|
|
123
|
-
Static.Const<RBrace>
|
|
124
|
-
], ModuleDeclarationMapping>;
|
|
50
|
+
Static.Const<LAngle>,
|
|
51
|
+
Elements,
|
|
52
|
+
Static.Const<RAngle>
|
|
53
|
+
], GenericReferenceMapping>;
|
|
125
54
|
interface ReferenceMapping extends Static.IMapping {
|
|
126
|
-
output: this['context'] extends
|
|
55
|
+
output: this['context'] extends t.TProperties ? this['input'] extends string ? Dereference<this['context'], this['input']> : never : never;
|
|
127
56
|
}
|
|
128
57
|
type Reference = Static.Ident<ReferenceMapping>;
|
|
129
58
|
interface LiteralBooleanMapping extends Static.IMapping {
|
|
130
|
-
output: this['input'] extends `${infer S extends boolean}` ?
|
|
59
|
+
output: this['input'] extends `${infer S extends boolean}` ? t.TLiteral<S> : never;
|
|
131
60
|
}
|
|
132
61
|
interface LiteralNumberMapping extends Static.IMapping {
|
|
133
|
-
output: this['input'] extends `${infer S extends number}` ?
|
|
62
|
+
output: this['input'] extends `${infer S extends number}` ? t.TLiteral<S> : never;
|
|
134
63
|
}
|
|
135
64
|
interface LiteralStringMapping extends Static.IMapping {
|
|
136
|
-
output: this['input'] extends `${infer S extends string}` ?
|
|
65
|
+
output: this['input'] extends `${infer S extends string}` ? t.TLiteral<S> : never;
|
|
137
66
|
}
|
|
138
67
|
type Literal = Static.Union<[
|
|
139
68
|
Static.Union<[Static.Const<'true'>, Static.Const<'false'>], LiteralBooleanMapping>,
|
|
@@ -141,18 +70,18 @@ type Literal = Static.Union<[
|
|
|
141
70
|
Static.String<[DoubleQuote, SingleQuote, Tilde], LiteralStringMapping>
|
|
142
71
|
]>;
|
|
143
72
|
type Keyword = Static.Union<[
|
|
144
|
-
Static.Const<'any', Static.As<
|
|
145
|
-
Static.Const<'bigint', Static.As<
|
|
146
|
-
Static.Const<'boolean', Static.As<
|
|
147
|
-
Static.Const<'integer', Static.As<
|
|
148
|
-
Static.Const<'never', Static.As<
|
|
149
|
-
Static.Const<'null', Static.As<
|
|
150
|
-
Static.Const<'number', Static.As<
|
|
151
|
-
Static.Const<'string', Static.As<
|
|
152
|
-
Static.Const<'symbol', Static.As<
|
|
153
|
-
Static.Const<'undefined', Static.As<
|
|
154
|
-
Static.Const<'unknown', Static.As<
|
|
155
|
-
Static.Const<'void', Static.As<
|
|
73
|
+
Static.Const<'any', Static.As<t.TAny>>,
|
|
74
|
+
Static.Const<'bigint', Static.As<t.TBigInt>>,
|
|
75
|
+
Static.Const<'boolean', Static.As<t.TBoolean>>,
|
|
76
|
+
Static.Const<'integer', Static.As<t.TInteger>>,
|
|
77
|
+
Static.Const<'never', Static.As<t.TNever>>,
|
|
78
|
+
Static.Const<'null', Static.As<t.TNull>>,
|
|
79
|
+
Static.Const<'number', Static.As<t.TNumber>>,
|
|
80
|
+
Static.Const<'string', Static.As<t.TString>>,
|
|
81
|
+
Static.Const<'symbol', Static.As<t.TSymbol>>,
|
|
82
|
+
Static.Const<'undefined', Static.As<t.TUndefined>>,
|
|
83
|
+
Static.Const<'unknown', Static.As<t.TUnknown>>,
|
|
84
|
+
Static.Const<'void', Static.As<t.TVoid>>
|
|
156
85
|
]>;
|
|
157
86
|
interface KeyOfMapping extends Static.IMapping {
|
|
158
87
|
output: this['input'] extends [] ? false : true;
|
|
@@ -162,7 +91,7 @@ type KeyOf = Static.Union<[
|
|
|
162
91
|
Static.Tuple<[]>
|
|
163
92
|
], KeyOfMapping>;
|
|
164
93
|
interface IndexArrayMapping extends Static.IMapping {
|
|
165
|
-
output: (this['input'] extends [LBracket, infer Type extends
|
|
94
|
+
output: (this['input'] extends [LBracket, infer Type extends t.TSchema, RBracket, infer Rest extends unknown[]] ? [[Type], ...Rest] : this['input'] extends [LBracket, RBracket, infer Rest extends unknown[]] ? [[], ...Rest] : [
|
|
166
95
|
]);
|
|
167
96
|
}
|
|
168
97
|
type IndexArray = Static.Union<[
|
|
@@ -171,14 +100,14 @@ type IndexArray = Static.Union<[
|
|
|
171
100
|
Static.Tuple<[]>
|
|
172
101
|
], IndexArrayMapping>;
|
|
173
102
|
interface ExtendsMapping extends Static.IMapping {
|
|
174
|
-
output: this['input'] extends ['extends', infer Type extends
|
|
103
|
+
output: this['input'] extends ['extends', infer Type extends t.TSchema, Question, infer True extends t.TSchema, Colon, infer False extends t.TSchema] ? [Type, True, False] : [];
|
|
175
104
|
}
|
|
176
105
|
type Extends = Static.Union<[
|
|
177
106
|
Static.Tuple<[Static.Const<'extends'>, Type, Static.Const<Question>, Type, Static.Const<Colon>, Type]>,
|
|
178
107
|
Static.Tuple<[]>
|
|
179
108
|
], ExtendsMapping>;
|
|
180
109
|
interface BaseMapping extends Static.IMapping {
|
|
181
|
-
output: (this['input'] extends [LParen, infer Type extends
|
|
110
|
+
output: (this['input'] extends [LParen, infer Type extends t.TSchema, RParen] ? Type : this['input'] extends [infer Type extends t.TSchema] ? Type : never);
|
|
182
111
|
}
|
|
183
112
|
type Base = Static.Union<[
|
|
184
113
|
Static.Tuple<[
|
|
@@ -199,6 +128,7 @@ type Base = Static.Union<[
|
|
|
199
128
|
Iterator,
|
|
200
129
|
ConstructorParameters,
|
|
201
130
|
FunctionParameters,
|
|
131
|
+
Argument,
|
|
202
132
|
InstanceType,
|
|
203
133
|
ReturnType,
|
|
204
134
|
Awaited,
|
|
@@ -217,14 +147,15 @@ type Base = Static.Union<[
|
|
|
217
147
|
Uncapitalize,
|
|
218
148
|
Date,
|
|
219
149
|
Uint8Array,
|
|
150
|
+
GenericReference,
|
|
220
151
|
Reference
|
|
221
152
|
]>
|
|
222
153
|
]>
|
|
223
154
|
], BaseMapping>;
|
|
224
|
-
type FactorExtends<Type extends
|
|
225
|
-
type FactorIndexArray<Type extends
|
|
155
|
+
type FactorExtends<Type extends t.TSchema, Extends extends unknown[]> = (Extends extends [infer Right extends t.TSchema, infer True extends t.TSchema, infer False extends t.TSchema] ? t.TExtends<Type, Right, True, False> : Type);
|
|
156
|
+
type FactorIndexArray<Type extends t.TSchema, IndexArray extends unknown[]> = (IndexArray extends [...infer Left extends unknown[], infer Right extends t.TSchema[]] ? (Right extends [infer Indexer extends t.TSchema] ? t.TIndex<FactorIndexArray<Type, Left>, t.TIndexPropertyKeys<Indexer>> : Right extends [] ? t.TArray<FactorIndexArray<Type, Left>> : t.TNever) : Type);
|
|
226
157
|
interface FactorMapping extends Static.IMapping {
|
|
227
|
-
output: this['input'] extends [infer KeyOf extends boolean, infer Type extends
|
|
158
|
+
output: this['input'] extends [infer KeyOf extends boolean, infer Type extends t.TSchema, infer IndexArray extends unknown[], infer Extends extends unknown[]] ? KeyOf extends true ? FactorExtends<t.TKeyOf<FactorIndexArray<Type, IndexArray>>, Extends> : FactorExtends<FactorIndexArray<Type, IndexArray>, Extends> : never;
|
|
228
159
|
}
|
|
229
160
|
type Factor = Static.Tuple<[
|
|
230
161
|
KeyOf,
|
|
@@ -232,9 +163,9 @@ type Factor = Static.Tuple<[
|
|
|
232
163
|
IndexArray,
|
|
233
164
|
Extends
|
|
234
165
|
], FactorMapping>;
|
|
235
|
-
type ExprBinaryReduce<Left extends
|
|
166
|
+
type ExprBinaryReduce<Left extends t.TSchema, Rest extends unknown[]> = (Rest extends [infer Operator extends unknown, infer Right extends t.TSchema, infer Next extends unknown[]] ? (ExprBinaryReduce<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);
|
|
236
167
|
interface ExprBinaryMapping extends Static.IMapping {
|
|
237
|
-
output: (this['input'] extends [infer Left extends
|
|
168
|
+
output: (this['input'] extends [infer Left extends t.TSchema, infer Rest extends unknown[]] ? ExprBinaryReduce<Left, Rest> : []);
|
|
238
169
|
}
|
|
239
170
|
type ExprTermTail = Static.Union<[
|
|
240
171
|
Static.Tuple<[Static.Const<'&'>, Factor, ExprTermTail]>,
|
|
@@ -252,7 +183,7 @@ type Expr = Static.Tuple<[
|
|
|
252
183
|
ExprTerm,
|
|
253
184
|
ExprTail
|
|
254
185
|
], ExprBinaryMapping>;
|
|
255
|
-
type Type = Expr;
|
|
186
|
+
export type Type = Expr;
|
|
256
187
|
interface PropertyKeyStringMapping extends Static.IMapping {
|
|
257
188
|
output: this['input'];
|
|
258
189
|
}
|
|
@@ -267,17 +198,17 @@ interface OptionalMapping extends Static.IMapping {
|
|
|
267
198
|
}
|
|
268
199
|
type Optional = Static.Union<[Static.Tuple<[Static.Const<Question>]>, Static.Tuple<[]>], OptionalMapping>;
|
|
269
200
|
interface PropertyMapping extends Static.IMapping {
|
|
270
|
-
output: this['input'] extends [infer IsReadonly extends boolean, infer Key extends string, infer IsOptional extends boolean, string, infer Type extends
|
|
201
|
+
output: this['input'] extends [infer IsReadonly extends boolean, infer Key extends string, infer IsOptional extends boolean, string, infer Type extends t.TSchema] ? {
|
|
271
202
|
[_ in Key]: ([
|
|
272
203
|
IsReadonly,
|
|
273
204
|
IsOptional
|
|
274
|
-
] extends [true, true] ?
|
|
205
|
+
] extends [true, true] ? t.TReadonlyOptional<Type> : [
|
|
275
206
|
IsReadonly,
|
|
276
207
|
IsOptional
|
|
277
|
-
] extends [true, false] ?
|
|
208
|
+
] extends [true, false] ? t.TReadonly<Type> : [
|
|
278
209
|
IsReadonly,
|
|
279
210
|
IsOptional
|
|
280
|
-
] extends [false, true] ?
|
|
211
|
+
] extends [false, true] ? t.TOptional<Type> : Type);
|
|
281
212
|
} : never;
|
|
282
213
|
}
|
|
283
214
|
type Property = Static.Tuple<[Readonly, PropertyKey, Optional, Static.Const<Colon>, Type], PropertyMapping>;
|
|
@@ -288,13 +219,13 @@ type PropertyDelimiter = Static.Union<[
|
|
|
288
219
|
Static.Tuple<[Static.Const<SemiColon>]>,
|
|
289
220
|
Static.Tuple<[Static.Const<Newline>]>
|
|
290
221
|
]>;
|
|
291
|
-
type PropertiesReduce<PropertiesArray extends
|
|
222
|
+
type PropertiesReduce<PropertiesArray extends t.TProperties[], Result extends t.TProperties = {}> = (PropertiesArray extends [infer Left extends t.TProperties, ...infer Right extends t.TProperties[]] ? PropertiesReduce<Right, t.Evaluate<Result & Left>> : Result);
|
|
292
223
|
interface PropertiesMapping extends Static.IMapping {
|
|
293
|
-
output: this['input'] extends
|
|
224
|
+
output: this['input'] extends t.TProperties[] ? PropertiesReduce<this['input']> : never;
|
|
294
225
|
}
|
|
295
226
|
type Properties = Static.Union<[Delimit<Property, PropertyDelimiter>], PropertiesMapping>;
|
|
296
227
|
interface ObjectMapping extends Static.IMapping {
|
|
297
|
-
output: this['input'] extends [unknown, infer Properties extends
|
|
228
|
+
output: this['input'] extends [unknown, infer Properties extends t.TProperties, unknown] ? t.TObject<Properties> : never;
|
|
298
229
|
}
|
|
299
230
|
type Object = Static.Tuple<[
|
|
300
231
|
Static.Const<LBrace>,
|
|
@@ -303,7 +234,7 @@ type Object = Static.Tuple<[
|
|
|
303
234
|
], ObjectMapping>;
|
|
304
235
|
type Elements = Delimit<Type, Static.Const<Comma>>;
|
|
305
236
|
interface TupleMapping extends Static.IMapping {
|
|
306
|
-
output: this['input'] extends [unknown, infer Elements extends
|
|
237
|
+
output: this['input'] extends [unknown, infer Elements extends t.TSchema[], unknown] ? t.TTuple<Elements> : never;
|
|
307
238
|
}
|
|
308
239
|
type Tuple = Static.Tuple<[
|
|
309
240
|
Static.Const<LBracket>,
|
|
@@ -311,7 +242,7 @@ type Tuple = Static.Tuple<[
|
|
|
311
242
|
Static.Const<RBracket>
|
|
312
243
|
], TupleMapping>;
|
|
313
244
|
interface ParameterMapping extends Static.IMapping {
|
|
314
|
-
output: this['input'] extends [string, Colon, infer Type extends
|
|
245
|
+
output: this['input'] extends [string, Colon, infer Type extends t.TSchema] ? Type : never;
|
|
315
246
|
}
|
|
316
247
|
type Parameter = Static.Tuple<[
|
|
317
248
|
Static.Ident,
|
|
@@ -320,7 +251,7 @@ type Parameter = Static.Tuple<[
|
|
|
320
251
|
], ParameterMapping>;
|
|
321
252
|
type Parameters = Delimit<Parameter, Static.Const<Comma>>;
|
|
322
253
|
interface FunctionMapping extends Static.IMapping {
|
|
323
|
-
output: this['input'] extends [LParen, infer Parameters extends
|
|
254
|
+
output: this['input'] extends [LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer ReturnType extends t.TSchema] ? t.TFunction<Parameters, ReturnType> : never;
|
|
324
255
|
}
|
|
325
256
|
type Function = Static.Tuple<[
|
|
326
257
|
Static.Const<LParen>,
|
|
@@ -330,7 +261,7 @@ type Function = Static.Tuple<[
|
|
|
330
261
|
Type
|
|
331
262
|
], FunctionMapping>;
|
|
332
263
|
interface ConstructorMapping extends Static.IMapping {
|
|
333
|
-
output: this['input'] extends ['new', LParen, infer Parameters extends
|
|
264
|
+
output: this['input'] extends ['new', LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer InstanceType extends t.TSchema] ? t.TConstructor<Parameters, InstanceType> : never;
|
|
334
265
|
}
|
|
335
266
|
type Constructor = Static.Tuple<[
|
|
336
267
|
Static.Const<'new'>,
|
|
@@ -341,7 +272,7 @@ type Constructor = Static.Tuple<[
|
|
|
341
272
|
Type
|
|
342
273
|
], ConstructorMapping>;
|
|
343
274
|
interface MappedMapping extends Static.IMapping {
|
|
344
|
-
output: this['input'] extends [LBrace, LBracket, infer _Key extends string, 'in', infer _Right extends
|
|
275
|
+
output: this['input'] extends [LBrace, LBracket, infer _Key extends string, 'in', infer _Right extends t.TSchema, RBracket, Colon, infer Type extends t.TSchema, RBrace] ? t.TLiteral<'Mapped types not supported'> : this['input'];
|
|
345
276
|
}
|
|
346
277
|
type Mapped = Static.Tuple<[
|
|
347
278
|
Static.Const<LBrace>,
|
|
@@ -355,7 +286,7 @@ type Mapped = Static.Tuple<[
|
|
|
355
286
|
Static.Const<RBrace>
|
|
356
287
|
], MappedMapping>;
|
|
357
288
|
interface ArrayMapping extends Static.IMapping {
|
|
358
|
-
output: this['input'] extends ['Array', LAngle, infer Type extends
|
|
289
|
+
output: this['input'] extends ['Array', LAngle, infer Type extends t.TSchema, RAngle] ? t.TArray<Type> : never;
|
|
359
290
|
}
|
|
360
291
|
type Array = Static.Tuple<[
|
|
361
292
|
Static.Const<'Array'>,
|
|
@@ -364,7 +295,7 @@ type Array = Static.Tuple<[
|
|
|
364
295
|
Static.Const<RAngle>
|
|
365
296
|
], ArrayMapping>;
|
|
366
297
|
interface AsyncIteratorMapping extends Static.IMapping {
|
|
367
|
-
output: this['input'] extends ['AsyncIterator', LAngle, infer Type extends
|
|
298
|
+
output: this['input'] extends ['AsyncIterator', LAngle, infer Type extends t.TSchema, RAngle] ? t.TAsyncIterator<Type> : never;
|
|
368
299
|
}
|
|
369
300
|
type AsyncIterator = Static.Tuple<[
|
|
370
301
|
Static.Const<'AsyncIterator'>,
|
|
@@ -373,7 +304,7 @@ type AsyncIterator = Static.Tuple<[
|
|
|
373
304
|
Static.Const<RAngle>
|
|
374
305
|
], AsyncIteratorMapping>;
|
|
375
306
|
interface IteratorMapping extends Static.IMapping {
|
|
376
|
-
output: this['input'] extends ['Iterator', LAngle, infer Type extends
|
|
307
|
+
output: this['input'] extends ['Iterator', LAngle, infer Type extends t.TSchema, RAngle] ? t.TIterator<Type> : never;
|
|
377
308
|
}
|
|
378
309
|
type Iterator = Static.Tuple<[
|
|
379
310
|
Static.Const<'Iterator'>,
|
|
@@ -382,7 +313,7 @@ type Iterator = Static.Tuple<[
|
|
|
382
313
|
Static.Const<RAngle>
|
|
383
314
|
], IteratorMapping>;
|
|
384
315
|
interface ConstructorParametersMapping extends Static.IMapping {
|
|
385
|
-
output: this['input'] extends ['ConstructorParameters', LAngle, infer Type extends
|
|
316
|
+
output: this['input'] extends ['ConstructorParameters', LAngle, infer Type extends t.TSchema, RAngle] ? t.TConstructorParameters<Type> : never;
|
|
386
317
|
}
|
|
387
318
|
type ConstructorParameters = Static.Tuple<[
|
|
388
319
|
Static.Const<'ConstructorParameters'>,
|
|
@@ -391,7 +322,7 @@ type ConstructorParameters = Static.Tuple<[
|
|
|
391
322
|
Static.Const<RAngle>
|
|
392
323
|
], ConstructorParametersMapping>;
|
|
393
324
|
interface FunctionParametersMapping extends Static.IMapping {
|
|
394
|
-
output: this['input'] extends ['Parameters', LAngle, infer Type extends
|
|
325
|
+
output: this['input'] extends ['Parameters', LAngle, infer Type extends t.TSchema, RAngle] ? t.TParameters<Type> : never;
|
|
395
326
|
}
|
|
396
327
|
type FunctionParameters = Static.Tuple<[
|
|
397
328
|
Static.Const<'Parameters'>,
|
|
@@ -400,7 +331,7 @@ type FunctionParameters = Static.Tuple<[
|
|
|
400
331
|
Static.Const<RAngle>
|
|
401
332
|
], FunctionParametersMapping>;
|
|
402
333
|
interface InstanceTypeMapping extends Static.IMapping {
|
|
403
|
-
output: this['input'] extends ['InstanceType', LAngle, infer Type extends
|
|
334
|
+
output: this['input'] extends ['InstanceType', LAngle, infer Type extends t.TSchema, RAngle] ? t.TInstanceType<Type> : never;
|
|
404
335
|
}
|
|
405
336
|
type InstanceType = Static.Tuple<[
|
|
406
337
|
Static.Const<'InstanceType'>,
|
|
@@ -409,7 +340,7 @@ type InstanceType = Static.Tuple<[
|
|
|
409
340
|
Static.Const<RAngle>
|
|
410
341
|
], InstanceTypeMapping>;
|
|
411
342
|
interface ReturnTypeMapping extends Static.IMapping {
|
|
412
|
-
output: this['input'] extends ['ReturnType', LAngle, infer Type extends
|
|
343
|
+
output: this['input'] extends ['ReturnType', LAngle, infer Type extends t.TSchema, RAngle] ? t.TReturnType<Type> : never;
|
|
413
344
|
}
|
|
414
345
|
type ReturnType = Static.Tuple<[
|
|
415
346
|
Static.Const<'ReturnType'>,
|
|
@@ -417,8 +348,17 @@ type ReturnType = Static.Tuple<[
|
|
|
417
348
|
Type,
|
|
418
349
|
Static.Const<RAngle>
|
|
419
350
|
], ReturnTypeMapping>;
|
|
351
|
+
interface ArgumentMapping extends Static.IMapping {
|
|
352
|
+
output: this['input'] extends ['Argument', LAngle, infer Type extends t.TSchema, RAngle] ? Type extends t.TLiteral<infer Index extends number> ? t.TArgument<Index> : t.TNever : never;
|
|
353
|
+
}
|
|
354
|
+
type Argument = Static.Tuple<[
|
|
355
|
+
Static.Const<'Argument'>,
|
|
356
|
+
Static.Const<LAngle>,
|
|
357
|
+
Type,
|
|
358
|
+
Static.Const<RAngle>
|
|
359
|
+
], ArgumentMapping>;
|
|
420
360
|
interface AwaitedMapping extends Static.IMapping {
|
|
421
|
-
output: this['input'] extends ['Awaited', LAngle, infer Type extends
|
|
361
|
+
output: this['input'] extends ['Awaited', LAngle, infer Type extends t.TSchema, RAngle] ? t.TAwaited<Type> : never;
|
|
422
362
|
}
|
|
423
363
|
type Awaited = Static.Tuple<[
|
|
424
364
|
Static.Const<'Awaited'>,
|
|
@@ -427,7 +367,7 @@ type Awaited = Static.Tuple<[
|
|
|
427
367
|
Static.Const<RAngle>
|
|
428
368
|
], AwaitedMapping>;
|
|
429
369
|
interface PromiseMapping extends Static.IMapping {
|
|
430
|
-
output: this['input'] extends ['Promise', LAngle, infer Type extends
|
|
370
|
+
output: this['input'] extends ['Promise', LAngle, infer Type extends t.TSchema, RAngle] ? t.TPromise<Type> : never;
|
|
431
371
|
}
|
|
432
372
|
type Promise = Static.Tuple<[
|
|
433
373
|
Static.Const<'Promise'>,
|
|
@@ -436,7 +376,7 @@ type Promise = Static.Tuple<[
|
|
|
436
376
|
Static.Const<RAngle>
|
|
437
377
|
], PromiseMapping>;
|
|
438
378
|
interface RecordMapping extends Static.IMapping {
|
|
439
|
-
output: this['input'] extends ['Record', LAngle, infer Key extends
|
|
379
|
+
output: this['input'] extends ['Record', LAngle, infer Key extends t.TSchema, Comma, infer Type extends t.TSchema, RAngle] ? t.TRecord<Key, Type> : never;
|
|
440
380
|
}
|
|
441
381
|
type Record = Static.Tuple<[
|
|
442
382
|
Static.Const<'Record'>,
|
|
@@ -447,7 +387,7 @@ type Record = Static.Tuple<[
|
|
|
447
387
|
Static.Const<RAngle>
|
|
448
388
|
], RecordMapping>;
|
|
449
389
|
interface PartialMapping extends Static.IMapping {
|
|
450
|
-
output: this['input'] extends ['Partial', LAngle, infer Type extends
|
|
390
|
+
output: this['input'] extends ['Partial', LAngle, infer Type extends t.TSchema, RAngle] ? t.TPartial<Type> : never;
|
|
451
391
|
}
|
|
452
392
|
type Partial = Static.Tuple<[
|
|
453
393
|
Static.Const<'Partial'>,
|
|
@@ -456,7 +396,7 @@ type Partial = Static.Tuple<[
|
|
|
456
396
|
Static.Const<RAngle>
|
|
457
397
|
], PartialMapping>;
|
|
458
398
|
interface RequiredMapping extends Static.IMapping {
|
|
459
|
-
output: this['input'] extends ['Required', LAngle, infer Type extends
|
|
399
|
+
output: this['input'] extends ['Required', LAngle, infer Type extends t.TSchema, RAngle] ? t.TRequired<Type> : never;
|
|
460
400
|
}
|
|
461
401
|
type Required = Static.Tuple<[
|
|
462
402
|
Static.Const<'Required'>,
|
|
@@ -465,7 +405,7 @@ type Required = Static.Tuple<[
|
|
|
465
405
|
Static.Const<RAngle>
|
|
466
406
|
], RequiredMapping>;
|
|
467
407
|
interface PickMapping extends Static.IMapping {
|
|
468
|
-
output: this['input'] extends ['Pick', LAngle, infer Type extends
|
|
408
|
+
output: this['input'] extends ['Pick', LAngle, infer Type extends t.TSchema, Comma, infer Key extends t.TSchema, RAngle] ? t.TPick<Type, Key> : never;
|
|
469
409
|
}
|
|
470
410
|
type Pick = Static.Tuple<[
|
|
471
411
|
Static.Const<'Pick'>,
|
|
@@ -476,7 +416,7 @@ type Pick = Static.Tuple<[
|
|
|
476
416
|
Static.Const<RAngle>
|
|
477
417
|
], PickMapping>;
|
|
478
418
|
interface OmitMapping extends Static.IMapping {
|
|
479
|
-
output: this['input'] extends ['Omit', LAngle, infer Type extends
|
|
419
|
+
output: this['input'] extends ['Omit', LAngle, infer Type extends t.TSchema, Comma, infer Key extends t.TSchema, RAngle] ? t.TOmit<Type, Key> : never;
|
|
480
420
|
}
|
|
481
421
|
type Omit = Static.Tuple<[
|
|
482
422
|
Static.Const<'Omit'>,
|
|
@@ -487,7 +427,7 @@ type Omit = Static.Tuple<[
|
|
|
487
427
|
Static.Const<RAngle>
|
|
488
428
|
], OmitMapping>;
|
|
489
429
|
interface ExcludeMapping extends Static.IMapping {
|
|
490
|
-
output: this['input'] extends ['Exclude', LAngle, infer Type extends
|
|
430
|
+
output: this['input'] extends ['Exclude', LAngle, infer Type extends t.TSchema, Comma, infer PropertyKey extends t.TSchema, RAngle] ? t.TExclude<Type, PropertyKey> : never;
|
|
491
431
|
}
|
|
492
432
|
type Exclude = Static.Tuple<[
|
|
493
433
|
Static.Const<'Exclude'>,
|
|
@@ -498,7 +438,7 @@ type Exclude = Static.Tuple<[
|
|
|
498
438
|
Static.Const<RAngle>
|
|
499
439
|
], ExcludeMapping>;
|
|
500
440
|
interface ExtractMapping extends Static.IMapping {
|
|
501
|
-
output: this['input'] extends ['Extract', LAngle, infer Type extends
|
|
441
|
+
output: this['input'] extends ['Extract', LAngle, infer Type extends t.TSchema, Comma, infer PropertyKey extends t.TSchema, RAngle] ? t.TExtract<Type, PropertyKey> : never;
|
|
502
442
|
}
|
|
503
443
|
type Extract = Static.Tuple<[
|
|
504
444
|
Static.Const<'Extract'>,
|
|
@@ -509,7 +449,7 @@ type Extract = Static.Tuple<[
|
|
|
509
449
|
Static.Const<RAngle>
|
|
510
450
|
], ExtractMapping>;
|
|
511
451
|
interface UppercaseMapping extends Static.IMapping {
|
|
512
|
-
output: this['input'] extends ['Uppercase', LAngle, infer Type extends
|
|
452
|
+
output: this['input'] extends ['Uppercase', LAngle, infer Type extends t.TSchema, RAngle] ? t.TUppercase<Type> : never;
|
|
513
453
|
}
|
|
514
454
|
type Uppercase = Static.Tuple<[
|
|
515
455
|
Static.Const<'Uppercase'>,
|
|
@@ -518,7 +458,7 @@ type Uppercase = Static.Tuple<[
|
|
|
518
458
|
Static.Const<RAngle>
|
|
519
459
|
], UppercaseMapping>;
|
|
520
460
|
interface LowercaseMapping extends Static.IMapping {
|
|
521
|
-
output: this['input'] extends ['Lowercase', LAngle, infer Type extends
|
|
461
|
+
output: this['input'] extends ['Lowercase', LAngle, infer Type extends t.TSchema, RAngle] ? t.TLowercase<Type> : never;
|
|
522
462
|
}
|
|
523
463
|
type Lowercase = Static.Tuple<[
|
|
524
464
|
Static.Const<'Lowercase'>,
|
|
@@ -527,7 +467,7 @@ type Lowercase = Static.Tuple<[
|
|
|
527
467
|
Static.Const<RAngle>
|
|
528
468
|
], LowercaseMapping>;
|
|
529
469
|
interface CapitalizeMapping extends Static.IMapping {
|
|
530
|
-
output: this['input'] extends ['Capitalize', LAngle, infer Type extends
|
|
470
|
+
output: this['input'] extends ['Capitalize', LAngle, infer Type extends t.TSchema, RAngle] ? t.TCapitalize<Type> : never;
|
|
531
471
|
}
|
|
532
472
|
type Capitalize = Static.Tuple<[
|
|
533
473
|
Static.Const<'Capitalize'>,
|
|
@@ -536,7 +476,7 @@ type Capitalize = Static.Tuple<[
|
|
|
536
476
|
Static.Const<RAngle>
|
|
537
477
|
], CapitalizeMapping>;
|
|
538
478
|
interface UncapitalizeMapping extends Static.IMapping {
|
|
539
|
-
output: this['input'] extends ['Uncapitalize', LAngle, infer Type extends
|
|
479
|
+
output: this['input'] extends ['Uncapitalize', LAngle, infer Type extends t.TSchema, RAngle] ? t.TUncapitalize<Type> : never;
|
|
540
480
|
}
|
|
541
481
|
type Uncapitalize = Static.Tuple<[
|
|
542
482
|
Static.Const<'Uncapitalize'>,
|
|
@@ -544,12 +484,6 @@ type Uncapitalize = Static.Tuple<[
|
|
|
544
484
|
Type,
|
|
545
485
|
Static.Const<RAngle>
|
|
546
486
|
], UncapitalizeMapping>;
|
|
547
|
-
type Date = Static.Const<'Date', Static.As<
|
|
548
|
-
type Uint8Array = Static.Const<'Uint8Array', Static.As<
|
|
549
|
-
export type Main = Static.Union<[
|
|
550
|
-
ModuleDeclaration,
|
|
551
|
-
TypeAliasDeclaration,
|
|
552
|
-
InterfaceDeclaration,
|
|
553
|
-
Type
|
|
554
|
-
]>;
|
|
487
|
+
type Date = Static.Const<'Date', Static.As<t.TDate>>;
|
|
488
|
+
type Uint8Array = Static.Const<'Uint8Array', Static.As<t.TUint8Array>>;
|
|
555
489
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Types from '../type/index';
|
|
2
|
+
import { Static } from '../parser/index';
|
|
3
|
+
import { Type } from './static';
|
|
4
|
+
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
|
|
5
|
+
export declare function NoInfer<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
6
|
+
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
|
|
7
|
+
export declare function NoInfer<Code extends string>(code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
8
|
+
/** Infers a TSchema type from TypeScript syntax. */
|
|
9
|
+
export type TSyntax<Context extends Record<PropertyKey, Types.TSchema>, Code extends string> = (Static.Parse<Type, Code, Context> extends [infer Type extends Types.TSchema, string] ? Type : Types.TNever);
|
|
10
|
+
/** Parses a TSchema type from TypeScript syntax */
|
|
11
|
+
export declare function Syntax<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): TSyntax<Context, Code>;
|
|
12
|
+
/** Parses a TSchema type from TypeScript syntax */
|
|
13
|
+
export declare function Syntax<Code extends string>(code: Code, options?: Types.SchemaOptions): TSyntax<{}, Code>;
|
|
14
|
+
/**
|
|
15
|
+
* Parses a TSchema type from Syntax.
|
|
16
|
+
* @deprecated Use Syntax() function
|
|
17
|
+
*/
|
|
18
|
+
export declare function Parse<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): TSyntax<Context, Code>;
|
|
19
|
+
/**
|
|
20
|
+
* Parses a TSchema type from Syntax.
|
|
21
|
+
* @deprecated Use Syntax() function
|
|
22
|
+
*/
|
|
23
|
+
export declare function Parse<Code extends string>(code: Code, options?: Types.SchemaOptions): TSyntax<{}, Code>;
|
|
24
|
+
/**
|
|
25
|
+
* Parses a TSchema from TypeScript Syntax
|
|
26
|
+
* @deprecated Use NoInfer() function
|
|
27
|
+
*/
|
|
28
|
+
export declare function ParseOnly<Context extends Record<PropertyKey, Types.TSchema>, Code extends string>(context: Context, code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Parses a TSchema from TypeScript Syntax
|
|
31
|
+
* @deprecated Use NoInfer() function
|
|
32
|
+
*/
|
|
33
|
+
export declare function ParseOnly<Code extends string>(code: Code, options?: Types.SchemaOptions): Types.TSchema | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NoInfer = NoInfer;
|
|
5
|
+
exports.Syntax = Syntax;
|
|
6
|
+
exports.Parse = Parse;
|
|
7
|
+
exports.ParseOnly = ParseOnly;
|
|
8
|
+
const Types = require("../type/index");
|
|
9
|
+
const runtime_1 = require("./runtime");
|
|
10
|
+
/** Parses a TSchema type from TypeScript syntax but does not infer schematics */
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
function NoInfer(...args) {
|
|
13
|
+
const withContext = typeof args[0] === 'string' ? false : true;
|
|
14
|
+
const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}];
|
|
15
|
+
const type = runtime_1.Module.Parse('Type', code, context)[0];
|
|
16
|
+
return Types.KindGuard.IsSchema(type)
|
|
17
|
+
? Types.CloneType(type, options)
|
|
18
|
+
: Types.Never(options);
|
|
19
|
+
}
|
|
20
|
+
/** Parses a TSchema type from TypeScript syntax */
|
|
21
|
+
function Syntax(...args) {
|
|
22
|
+
return NoInfer.apply(null, args);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parses a TSchema type from Syntax.
|
|
26
|
+
* @deprecated Use Syntax() function
|
|
27
|
+
*/
|
|
28
|
+
function Parse(...args) {
|
|
29
|
+
return NoInfer.apply(null, args);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parses a TSchema from TypeScript Syntax
|
|
33
|
+
* @deprecated Use NoInfer() function
|
|
34
|
+
*/
|
|
35
|
+
function ParseOnly(...args) {
|
|
36
|
+
return NoInfer.apply(null, args);
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
|
+
import { Kind } from '../symbols/index';
|
|
3
|
+
export interface TArgument<Index extends number = number> extends TSchema {
|
|
4
|
+
[Kind]: 'Argument';
|
|
5
|
+
static: unknown;
|
|
6
|
+
index: Index;
|
|
7
|
+
}
|
|
8
|
+
/** `[JavaScript]` Creates an Argument Type. */
|
|
9
|
+
export declare function Argument<Index extends number>(index: Index): TArgument<Index>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Argument = Argument;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
6
|
+
const index_1 = require("../symbols/index");
|
|
7
|
+
/** `[JavaScript]` Creates an Argument Type. */
|
|
8
|
+
function Argument(index) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Argument', index });
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './argument';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./argument"), exports);
|