@sinclair/typebox 0.34.15 → 0.34.16

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.
Files changed (83) hide show
  1. package/build/cjs/syntax/index.d.ts +1 -1
  2. package/build/cjs/syntax/index.js +1 -1
  3. package/build/cjs/syntax/runtime.d.ts +38 -54
  4. package/build/cjs/syntax/runtime.js +60 -202
  5. package/build/cjs/syntax/static.d.ts +62 -148
  6. package/build/cjs/syntax/syntax.d.ts +33 -0
  7. package/build/cjs/syntax/syntax.js +37 -0
  8. package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +3 -3
  9. package/build/cjs/type/constructor-parameters/constructor-parameters.js +3 -1
  10. package/build/cjs/type/instance-type/instance-type.d.ts +5 -4
  11. package/build/cjs/type/instance-type/instance-type.js +3 -1
  12. package/build/cjs/type/parameters/parameters.d.ts +3 -3
  13. package/build/cjs/type/parameters/parameters.js +3 -1
  14. package/build/cjs/type/return-type/return-type.d.ts +5 -4
  15. package/build/cjs/type/return-type/return-type.js +3 -1
  16. package/build/cjs/type/type/javascript.d.ts +4 -4
  17. package/build/esm/syntax/index.d.mts +1 -1
  18. package/build/esm/syntax/index.mjs +1 -1
  19. package/build/esm/syntax/runtime.d.mts +38 -54
  20. package/build/esm/syntax/runtime.mjs +60 -202
  21. package/build/esm/syntax/static.d.mts +62 -148
  22. package/build/esm/syntax/syntax.d.mts +33 -0
  23. package/build/esm/syntax/syntax.mjs +30 -0
  24. package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +3 -3
  25. package/build/esm/type/constructor-parameters/constructor-parameters.mjs +3 -1
  26. package/build/esm/type/instance-type/instance-type.d.mts +5 -4
  27. package/build/esm/type/instance-type/instance-type.mjs +3 -1
  28. package/build/esm/type/parameters/parameters.d.mts +3 -3
  29. package/build/esm/type/parameters/parameters.mjs +3 -1
  30. package/build/esm/type/return-type/return-type.d.mts +5 -4
  31. package/build/esm/type/return-type/return-type.mjs +3 -1
  32. package/build/esm/type/type/javascript.d.mts +4 -4
  33. package/package.json +11 -1
  34. package/parser/package.json +4 -0
  35. package/readme.md +86 -160
  36. package/build/cjs/syntax/parse.d.ts +0 -15
  37. package/build/cjs/syntax/parse.js +0 -19
  38. package/build/esm/syntax/parse.d.mts +0 -15
  39. package/build/esm/syntax/parse.mjs +0 -14
  40. /package/build/cjs/{syntax/parsebox → parser}/index.d.ts +0 -0
  41. /package/build/cjs/{syntax/parsebox → parser}/index.js +0 -0
  42. /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.d.ts +0 -0
  43. /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.js +0 -0
  44. /package/build/cjs/{syntax/parsebox → parser}/runtime/index.d.ts +0 -0
  45. /package/build/cjs/{syntax/parsebox → parser}/runtime/index.js +0 -0
  46. /package/build/cjs/{syntax/parsebox → parser}/runtime/module.d.ts +0 -0
  47. /package/build/cjs/{syntax/parsebox → parser}/runtime/module.js +0 -0
  48. /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.d.ts +0 -0
  49. /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.js +0 -0
  50. /package/build/cjs/{syntax/parsebox → parser}/runtime/token.d.ts +0 -0
  51. /package/build/cjs/{syntax/parsebox → parser}/runtime/token.js +0 -0
  52. /package/build/cjs/{syntax/parsebox → parser}/runtime/types.d.ts +0 -0
  53. /package/build/cjs/{syntax/parsebox → parser}/runtime/types.js +0 -0
  54. /package/build/cjs/{syntax/parsebox → parser}/static/index.d.ts +0 -0
  55. /package/build/cjs/{syntax/parsebox → parser}/static/index.js +0 -0
  56. /package/build/cjs/{syntax/parsebox → parser}/static/parse.d.ts +0 -0
  57. /package/build/cjs/{syntax/parsebox → parser}/static/parse.js +0 -0
  58. /package/build/cjs/{syntax/parsebox → parser}/static/token.d.ts +0 -0
  59. /package/build/cjs/{syntax/parsebox → parser}/static/token.js +0 -0
  60. /package/build/cjs/{syntax/parsebox → parser}/static/types.d.ts +0 -0
  61. /package/build/cjs/{syntax/parsebox → parser}/static/types.js +0 -0
  62. /package/build/esm/{syntax/parsebox → parser}/index.d.mts +0 -0
  63. /package/build/esm/{syntax/parsebox → parser}/index.mjs +0 -0
  64. /package/build/esm/{syntax/parsebox → parser}/runtime/guard.d.mts +0 -0
  65. /package/build/esm/{syntax/parsebox → parser}/runtime/guard.mjs +0 -0
  66. /package/build/esm/{syntax/parsebox → parser}/runtime/index.d.mts +0 -0
  67. /package/build/esm/{syntax/parsebox → parser}/runtime/index.mjs +0 -0
  68. /package/build/esm/{syntax/parsebox → parser}/runtime/module.d.mts +0 -0
  69. /package/build/esm/{syntax/parsebox → parser}/runtime/module.mjs +0 -0
  70. /package/build/esm/{syntax/parsebox → parser}/runtime/parse.d.mts +0 -0
  71. /package/build/esm/{syntax/parsebox → parser}/runtime/parse.mjs +0 -0
  72. /package/build/esm/{syntax/parsebox → parser}/runtime/token.d.mts +0 -0
  73. /package/build/esm/{syntax/parsebox → parser}/runtime/token.mjs +0 -0
  74. /package/build/esm/{syntax/parsebox → parser}/runtime/types.d.mts +0 -0
  75. /package/build/esm/{syntax/parsebox → parser}/runtime/types.mjs +0 -0
  76. /package/build/esm/{syntax/parsebox → parser}/static/index.d.mts +0 -0
  77. /package/build/esm/{syntax/parsebox → parser}/static/index.mjs +0 -0
  78. /package/build/esm/{syntax/parsebox → parser}/static/parse.d.mts +0 -0
  79. /package/build/esm/{syntax/parsebox → parser}/static/parse.mjs +0 -0
  80. /package/build/esm/{syntax/parsebox → parser}/static/token.d.mts +0 -0
  81. /package/build/esm/{syntax/parsebox → parser}/static/token.mjs +0 -0
  82. /package/build/esm/{syntax/parsebox → parser}/static/types.d.mts +0 -0
  83. /package/build/esm/{syntax/parsebox → parser}/static/types.mjs +0 -0
@@ -1,5 +1,5 @@
1
- import { Static } from './parsebox/index.mjs';
2
- import * as Types from '../type/index.mjs';
1
+ import { Static } from '../parser/index.mjs';
2
+ import * as t from '../type/index.mjs';
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,19 @@ 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 Deref<Context extends Types.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : Types.TRef<Ref>);
46
- interface ExportModifierMapping extends Static.IMapping {
47
- output: this['input'] extends [string] ? true : false;
48
- }
49
- type ExportModifier = Static.Union<[
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'>,
86
- Static.Ident,
87
- Heritage,
88
- Static.Const<LBrace>,
89
- Properties,
90
- Static.Const<RBrace>
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>;
44
+ type Deref<Context extends t.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : t.TRef<Ref>);
125
45
  interface ReferenceMapping extends Static.IMapping {
126
- output: this['context'] extends Types.TProperties ? this['input'] extends string ? Deref<this['context'], this['input']> : never : never;
46
+ output: this['context'] extends t.TProperties ? this['input'] extends string ? Deref<this['context'], this['input']> : never : never;
127
47
  }
128
48
  type Reference = Static.Ident<ReferenceMapping>;
129
49
  interface LiteralBooleanMapping extends Static.IMapping {
130
- output: this['input'] extends `${infer S extends boolean}` ? Types.TLiteral<S> : never;
50
+ output: this['input'] extends `${infer S extends boolean}` ? t.TLiteral<S> : never;
131
51
  }
132
52
  interface LiteralNumberMapping extends Static.IMapping {
133
- output: this['input'] extends `${infer S extends number}` ? Types.TLiteral<S> : never;
53
+ output: this['input'] extends `${infer S extends number}` ? t.TLiteral<S> : never;
134
54
  }
135
55
  interface LiteralStringMapping extends Static.IMapping {
136
- output: this['input'] extends `${infer S extends string}` ? Types.TLiteral<S> : never;
56
+ output: this['input'] extends `${infer S extends string}` ? t.TLiteral<S> : never;
137
57
  }
138
58
  type Literal = Static.Union<[
139
59
  Static.Union<[Static.Const<'true'>, Static.Const<'false'>], LiteralBooleanMapping>,
@@ -141,18 +61,18 @@ type Literal = Static.Union<[
141
61
  Static.String<[DoubleQuote, SingleQuote, Tilde], LiteralStringMapping>
142
62
  ]>;
143
63
  type Keyword = Static.Union<[
144
- Static.Const<'any', Static.As<Types.TAny>>,
145
- Static.Const<'bigint', Static.As<Types.TBigInt>>,
146
- Static.Const<'boolean', Static.As<Types.TBoolean>>,
147
- Static.Const<'integer', Static.As<Types.TInteger>>,
148
- Static.Const<'never', Static.As<Types.TNever>>,
149
- Static.Const<'null', Static.As<Types.TNull>>,
150
- Static.Const<'number', Static.As<Types.TNumber>>,
151
- Static.Const<'string', Static.As<Types.TString>>,
152
- Static.Const<'symbol', Static.As<Types.TSymbol>>,
153
- Static.Const<'undefined', Static.As<Types.TUndefined>>,
154
- Static.Const<'unknown', Static.As<Types.TUnknown>>,
155
- Static.Const<'void', Static.As<Types.TVoid>>
64
+ Static.Const<'any', Static.As<t.TAny>>,
65
+ Static.Const<'bigint', Static.As<t.TBigInt>>,
66
+ Static.Const<'boolean', Static.As<t.TBoolean>>,
67
+ Static.Const<'integer', Static.As<t.TInteger>>,
68
+ Static.Const<'never', Static.As<t.TNever>>,
69
+ Static.Const<'null', Static.As<t.TNull>>,
70
+ Static.Const<'number', Static.As<t.TNumber>>,
71
+ Static.Const<'string', Static.As<t.TString>>,
72
+ Static.Const<'symbol', Static.As<t.TSymbol>>,
73
+ Static.Const<'undefined', Static.As<t.TUndefined>>,
74
+ Static.Const<'unknown', Static.As<t.TUnknown>>,
75
+ Static.Const<'void', Static.As<t.TVoid>>
156
76
  ]>;
157
77
  interface KeyOfMapping extends Static.IMapping {
158
78
  output: this['input'] extends [] ? false : true;
@@ -162,7 +82,7 @@ type KeyOf = Static.Union<[
162
82
  Static.Tuple<[]>
163
83
  ], KeyOfMapping>;
164
84
  interface IndexArrayMapping extends Static.IMapping {
165
- output: (this['input'] extends [LBracket, infer Type extends Types.TSchema, RBracket, infer Rest extends unknown[]] ? [[Type], ...Rest] : this['input'] extends [LBracket, RBracket, infer Rest extends unknown[]] ? [[], ...Rest] : [
85
+ 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
86
  ]);
167
87
  }
168
88
  type IndexArray = Static.Union<[
@@ -171,14 +91,14 @@ type IndexArray = Static.Union<[
171
91
  Static.Tuple<[]>
172
92
  ], IndexArrayMapping>;
173
93
  interface ExtendsMapping extends Static.IMapping {
174
- output: this['input'] extends ['extends', infer Type extends Types.TSchema, Question, infer True extends Types.TSchema, Colon, infer False extends Types.TSchema] ? [Type, True, False] : [];
94
+ 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
95
  }
176
96
  type Extends = Static.Union<[
177
97
  Static.Tuple<[Static.Const<'extends'>, Type, Static.Const<Question>, Type, Static.Const<Colon>, Type]>,
178
98
  Static.Tuple<[]>
179
99
  ], ExtendsMapping>;
180
100
  interface BaseMapping extends Static.IMapping {
181
- output: (this['input'] extends [LParen, infer Type extends Types.TSchema, RParen] ? Type : this['input'] extends [infer Type extends Types.TSchema] ? Type : never);
101
+ output: (this['input'] extends [LParen, infer Type extends t.TSchema, RParen] ? Type : this['input'] extends [infer Type extends t.TSchema] ? Type : never);
182
102
  }
183
103
  type Base = Static.Union<[
184
104
  Static.Tuple<[
@@ -221,10 +141,10 @@ type Base = Static.Union<[
221
141
  ]>
222
142
  ]>
223
143
  ], BaseMapping>;
224
- type FactorExtends<Type extends Types.TSchema, Extends extends unknown[]> = (Extends extends [infer Right extends Types.TSchema, infer True extends Types.TSchema, infer False extends Types.TSchema] ? Types.TExtends<Type, Right, True, False> : Type);
225
- type FactorIndexArray<Type extends Types.TSchema, IndexArray extends unknown[]> = (IndexArray extends [...infer Left extends unknown[], infer Right extends Types.TSchema[]] ? (Right extends [infer Indexer extends Types.TSchema] ? Types.TIndex<FactorIndexArray<Type, Left>, Types.TIndexPropertyKeys<Indexer>> : Right extends [] ? Types.TArray<FactorIndexArray<Type, Left>> : Types.TNever) : Type);
144
+ 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);
145
+ 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
146
  interface FactorMapping extends Static.IMapping {
227
- output: this['input'] extends [infer KeyOf extends boolean, infer Type extends Types.TSchema, infer IndexArray extends unknown[], infer Extends extends unknown[]] ? KeyOf extends true ? FactorExtends<Types.TKeyOf<FactorIndexArray<Type, IndexArray>>, Extends> : FactorExtends<FactorIndexArray<Type, IndexArray>, Extends> : never;
147
+ 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
148
  }
229
149
  type Factor = Static.Tuple<[
230
150
  KeyOf,
@@ -232,9 +152,9 @@ type Factor = Static.Tuple<[
232
152
  IndexArray,
233
153
  Extends
234
154
  ], FactorMapping>;
235
- type ExprBinaryReduce<Left extends Types.TSchema, Rest extends unknown[]> = (Rest extends [infer Operator extends unknown, infer Right extends Types.TSchema, infer Next extends unknown[]] ? (ExprBinaryReduce<Right, Next> extends infer Schema extends Types.TSchema ? (Operator extends '&' ? (Schema extends Types.TIntersect<infer Types extends Types.TSchema[]> ? Types.TIntersect<[Left, ...Types]> : Types.TIntersect<[Left, Schema]>) : Operator extends '|' ? (Schema extends Types.TUnion<infer Types extends Types.TSchema[]> ? Types.TUnion<[Left, ...Types]> : Types.TUnion<[Left, Schema]>) : never) : never) : Left);
155
+ 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
156
  interface ExprBinaryMapping extends Static.IMapping {
237
- output: (this['input'] extends [infer Left extends Types.TSchema, infer Rest extends unknown[]] ? ExprBinaryReduce<Left, Rest> : []);
157
+ output: (this['input'] extends [infer Left extends t.TSchema, infer Rest extends unknown[]] ? ExprBinaryReduce<Left, Rest> : []);
238
158
  }
239
159
  type ExprTermTail = Static.Union<[
240
160
  Static.Tuple<[Static.Const<'&'>, Factor, ExprTermTail]>,
@@ -252,7 +172,7 @@ type Expr = Static.Tuple<[
252
172
  ExprTerm,
253
173
  ExprTail
254
174
  ], ExprBinaryMapping>;
255
- type Type = Expr;
175
+ export type Type = Expr;
256
176
  interface PropertyKeyStringMapping extends Static.IMapping {
257
177
  output: this['input'];
258
178
  }
@@ -267,17 +187,17 @@ interface OptionalMapping extends Static.IMapping {
267
187
  }
268
188
  type Optional = Static.Union<[Static.Tuple<[Static.Const<Question>]>, Static.Tuple<[]>], OptionalMapping>;
269
189
  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 Types.TSchema] ? {
190
+ output: this['input'] extends [infer IsReadonly extends boolean, infer Key extends string, infer IsOptional extends boolean, string, infer Type extends t.TSchema] ? {
271
191
  [_ in Key]: ([
272
192
  IsReadonly,
273
193
  IsOptional
274
- ] extends [true, true] ? Types.TReadonlyOptional<Type> : [
194
+ ] extends [true, true] ? t.TReadonlyOptional<Type> : [
275
195
  IsReadonly,
276
196
  IsOptional
277
- ] extends [true, false] ? Types.TReadonly<Type> : [
197
+ ] extends [true, false] ? t.TReadonly<Type> : [
278
198
  IsReadonly,
279
199
  IsOptional
280
- ] extends [false, true] ? Types.TOptional<Type> : Type);
200
+ ] extends [false, true] ? t.TOptional<Type> : Type);
281
201
  } : never;
282
202
  }
283
203
  type Property = Static.Tuple<[Readonly, PropertyKey, Optional, Static.Const<Colon>, Type], PropertyMapping>;
@@ -288,13 +208,13 @@ type PropertyDelimiter = Static.Union<[
288
208
  Static.Tuple<[Static.Const<SemiColon>]>,
289
209
  Static.Tuple<[Static.Const<Newline>]>
290
210
  ]>;
291
- type PropertiesReduce<PropertiesArray extends Types.TProperties[], Result extends Types.TProperties = {}> = (PropertiesArray extends [infer Left extends Types.TProperties, ...infer Right extends Types.TProperties[]] ? PropertiesReduce<Right, Types.Evaluate<Result & Left>> : Result);
211
+ 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
212
  interface PropertiesMapping extends Static.IMapping {
293
- output: this['input'] extends Types.TProperties[] ? PropertiesReduce<this['input']> : never;
213
+ output: this['input'] extends t.TProperties[] ? PropertiesReduce<this['input']> : never;
294
214
  }
295
215
  type Properties = Static.Union<[Delimit<Property, PropertyDelimiter>], PropertiesMapping>;
296
216
  interface ObjectMapping extends Static.IMapping {
297
- output: this['input'] extends [unknown, infer Properties extends Types.TProperties, unknown] ? Types.TObject<Properties> : never;
217
+ output: this['input'] extends [unknown, infer Properties extends t.TProperties, unknown] ? t.TObject<Properties> : never;
298
218
  }
299
219
  type Object = Static.Tuple<[
300
220
  Static.Const<LBrace>,
@@ -303,7 +223,7 @@ type Object = Static.Tuple<[
303
223
  ], ObjectMapping>;
304
224
  type Elements = Delimit<Type, Static.Const<Comma>>;
305
225
  interface TupleMapping extends Static.IMapping {
306
- output: this['input'] extends [unknown, infer Elements extends Types.TSchema[], unknown] ? Types.TTuple<Elements> : never;
226
+ output: this['input'] extends [unknown, infer Elements extends t.TSchema[], unknown] ? t.TTuple<Elements> : never;
307
227
  }
308
228
  type Tuple = Static.Tuple<[
309
229
  Static.Const<LBracket>,
@@ -311,7 +231,7 @@ type Tuple = Static.Tuple<[
311
231
  Static.Const<RBracket>
312
232
  ], TupleMapping>;
313
233
  interface ParameterMapping extends Static.IMapping {
314
- output: this['input'] extends [string, Colon, infer Type extends Types.TSchema] ? Type : never;
234
+ output: this['input'] extends [string, Colon, infer Type extends t.TSchema] ? Type : never;
315
235
  }
316
236
  type Parameter = Static.Tuple<[
317
237
  Static.Ident,
@@ -320,7 +240,7 @@ type Parameter = Static.Tuple<[
320
240
  ], ParameterMapping>;
321
241
  type Parameters = Delimit<Parameter, Static.Const<Comma>>;
322
242
  interface FunctionMapping extends Static.IMapping {
323
- output: this['input'] extends [LParen, infer Parameters extends Types.TSchema[], RParen, '=>', infer ReturnType extends Types.TSchema] ? Types.TFunction<Parameters, ReturnType> : never;
243
+ output: this['input'] extends [LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer ReturnType extends t.TSchema] ? t.TFunction<Parameters, ReturnType> : never;
324
244
  }
325
245
  type Function = Static.Tuple<[
326
246
  Static.Const<LParen>,
@@ -330,7 +250,7 @@ type Function = Static.Tuple<[
330
250
  Type
331
251
  ], FunctionMapping>;
332
252
  interface ConstructorMapping extends Static.IMapping {
333
- output: this['input'] extends ['new', LParen, infer Parameters extends Types.TSchema[], RParen, '=>', infer InstanceType extends Types.TSchema] ? Types.TConstructor<Parameters, InstanceType> : never;
253
+ output: this['input'] extends ['new', LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer InstanceType extends t.TSchema] ? t.TConstructor<Parameters, InstanceType> : never;
334
254
  }
335
255
  type Constructor = Static.Tuple<[
336
256
  Static.Const<'new'>,
@@ -341,7 +261,7 @@ type Constructor = Static.Tuple<[
341
261
  Type
342
262
  ], ConstructorMapping>;
343
263
  interface MappedMapping extends Static.IMapping {
344
- output: this['input'] extends [LBrace, LBracket, infer _Key extends string, 'in', infer _Right extends Types.TSchema, RBracket, Colon, infer Type extends Types.TSchema, RBrace] ? Types.TLiteral<'Mapped types not supported'> : this['input'];
264
+ 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
265
  }
346
266
  type Mapped = Static.Tuple<[
347
267
  Static.Const<LBrace>,
@@ -355,7 +275,7 @@ type Mapped = Static.Tuple<[
355
275
  Static.Const<RBrace>
356
276
  ], MappedMapping>;
357
277
  interface ArrayMapping extends Static.IMapping {
358
- output: this['input'] extends ['Array', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TArray<Type> : never;
278
+ output: this['input'] extends ['Array', LAngle, infer Type extends t.TSchema, RAngle] ? t.TArray<Type> : never;
359
279
  }
360
280
  type Array = Static.Tuple<[
361
281
  Static.Const<'Array'>,
@@ -364,7 +284,7 @@ type Array = Static.Tuple<[
364
284
  Static.Const<RAngle>
365
285
  ], ArrayMapping>;
366
286
  interface AsyncIteratorMapping extends Static.IMapping {
367
- output: this['input'] extends ['AsyncIterator', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TAsyncIterator<Type> : never;
287
+ output: this['input'] extends ['AsyncIterator', LAngle, infer Type extends t.TSchema, RAngle] ? t.TAsyncIterator<Type> : never;
368
288
  }
369
289
  type AsyncIterator = Static.Tuple<[
370
290
  Static.Const<'AsyncIterator'>,
@@ -373,7 +293,7 @@ type AsyncIterator = Static.Tuple<[
373
293
  Static.Const<RAngle>
374
294
  ], AsyncIteratorMapping>;
375
295
  interface IteratorMapping extends Static.IMapping {
376
- output: this['input'] extends ['Iterator', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TIterator<Type> : never;
296
+ output: this['input'] extends ['Iterator', LAngle, infer Type extends t.TSchema, RAngle] ? t.TIterator<Type> : never;
377
297
  }
378
298
  type Iterator = Static.Tuple<[
379
299
  Static.Const<'Iterator'>,
@@ -382,7 +302,7 @@ type Iterator = Static.Tuple<[
382
302
  Static.Const<RAngle>
383
303
  ], IteratorMapping>;
384
304
  interface ConstructorParametersMapping extends Static.IMapping {
385
- output: this['input'] extends ['ConstructorParameters', LAngle, infer Type extends Types.TConstructor, RAngle] ? Types.TConstructorParameters<Type> : never;
305
+ output: this['input'] extends ['ConstructorParameters', LAngle, infer Type extends t.TSchema, RAngle] ? t.TConstructorParameters<Type> : never;
386
306
  }
387
307
  type ConstructorParameters = Static.Tuple<[
388
308
  Static.Const<'ConstructorParameters'>,
@@ -391,7 +311,7 @@ type ConstructorParameters = Static.Tuple<[
391
311
  Static.Const<RAngle>
392
312
  ], ConstructorParametersMapping>;
393
313
  interface FunctionParametersMapping extends Static.IMapping {
394
- output: this['input'] extends ['Parameters', LAngle, infer Type extends Types.TFunction, RAngle] ? Types.TParameters<Type> : never;
314
+ output: this['input'] extends ['Parameters', LAngle, infer Type extends t.TSchema, RAngle] ? t.TParameters<Type> : never;
395
315
  }
396
316
  type FunctionParameters = Static.Tuple<[
397
317
  Static.Const<'Parameters'>,
@@ -400,7 +320,7 @@ type FunctionParameters = Static.Tuple<[
400
320
  Static.Const<RAngle>
401
321
  ], FunctionParametersMapping>;
402
322
  interface InstanceTypeMapping extends Static.IMapping {
403
- output: this['input'] extends ['InstanceType', LAngle, infer Type extends Types.TConstructor, RAngle] ? Types.TInstanceType<Type> : never;
323
+ output: this['input'] extends ['InstanceType', LAngle, infer Type extends t.TSchema, RAngle] ? t.TInstanceType<Type> : never;
404
324
  }
405
325
  type InstanceType = Static.Tuple<[
406
326
  Static.Const<'InstanceType'>,
@@ -409,7 +329,7 @@ type InstanceType = Static.Tuple<[
409
329
  Static.Const<RAngle>
410
330
  ], InstanceTypeMapping>;
411
331
  interface ReturnTypeMapping extends Static.IMapping {
412
- output: this['input'] extends ['ReturnType', LAngle, infer Type extends Types.TFunction, RAngle] ? Types.TReturnType<Type> : never;
332
+ output: this['input'] extends ['ReturnType', LAngle, infer Type extends t.TSchema, RAngle] ? t.TReturnType<Type> : never;
413
333
  }
414
334
  type ReturnType = Static.Tuple<[
415
335
  Static.Const<'ReturnType'>,
@@ -418,7 +338,7 @@ type ReturnType = Static.Tuple<[
418
338
  Static.Const<RAngle>
419
339
  ], ReturnTypeMapping>;
420
340
  interface AwaitedMapping extends Static.IMapping {
421
- output: this['input'] extends ['Awaited', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TAwaited<Type> : never;
341
+ output: this['input'] extends ['Awaited', LAngle, infer Type extends t.TSchema, RAngle] ? t.TAwaited<Type> : never;
422
342
  }
423
343
  type Awaited = Static.Tuple<[
424
344
  Static.Const<'Awaited'>,
@@ -427,7 +347,7 @@ type Awaited = Static.Tuple<[
427
347
  Static.Const<RAngle>
428
348
  ], AwaitedMapping>;
429
349
  interface PromiseMapping extends Static.IMapping {
430
- output: this['input'] extends ['Promise', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TPromise<Type> : never;
350
+ output: this['input'] extends ['Promise', LAngle, infer Type extends t.TSchema, RAngle] ? t.TPromise<Type> : never;
431
351
  }
432
352
  type Promise = Static.Tuple<[
433
353
  Static.Const<'Promise'>,
@@ -436,7 +356,7 @@ type Promise = Static.Tuple<[
436
356
  Static.Const<RAngle>
437
357
  ], PromiseMapping>;
438
358
  interface RecordMapping extends Static.IMapping {
439
- output: this['input'] extends ['Record', LAngle, infer Key extends Types.TSchema, Comma, infer Type extends Types.TSchema, RAngle] ? Types.TRecord<Key, Type> : never;
359
+ output: this['input'] extends ['Record', LAngle, infer Key extends t.TSchema, Comma, infer Type extends t.TSchema, RAngle] ? t.TRecord<Key, Type> : never;
440
360
  }
441
361
  type Record = Static.Tuple<[
442
362
  Static.Const<'Record'>,
@@ -447,7 +367,7 @@ type Record = Static.Tuple<[
447
367
  Static.Const<RAngle>
448
368
  ], RecordMapping>;
449
369
  interface PartialMapping extends Static.IMapping {
450
- output: this['input'] extends ['Partial', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TPartial<Type> : never;
370
+ output: this['input'] extends ['Partial', LAngle, infer Type extends t.TSchema, RAngle] ? t.TPartial<Type> : never;
451
371
  }
452
372
  type Partial = Static.Tuple<[
453
373
  Static.Const<'Partial'>,
@@ -456,7 +376,7 @@ type Partial = Static.Tuple<[
456
376
  Static.Const<RAngle>
457
377
  ], PartialMapping>;
458
378
  interface RequiredMapping extends Static.IMapping {
459
- output: this['input'] extends ['Required', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TRequired<Type> : never;
379
+ output: this['input'] extends ['Required', LAngle, infer Type extends t.TSchema, RAngle] ? t.TRequired<Type> : never;
460
380
  }
461
381
  type Required = Static.Tuple<[
462
382
  Static.Const<'Required'>,
@@ -465,7 +385,7 @@ type Required = Static.Tuple<[
465
385
  Static.Const<RAngle>
466
386
  ], RequiredMapping>;
467
387
  interface PickMapping extends Static.IMapping {
468
- output: this['input'] extends ['Pick', LAngle, infer Type extends Types.TSchema, Comma, infer Key extends Types.TSchema, RAngle] ? Types.TPick<Type, Key> : never;
388
+ output: this['input'] extends ['Pick', LAngle, infer Type extends t.TSchema, Comma, infer Key extends t.TSchema, RAngle] ? t.TPick<Type, Key> : never;
469
389
  }
470
390
  type Pick = Static.Tuple<[
471
391
  Static.Const<'Pick'>,
@@ -476,7 +396,7 @@ type Pick = Static.Tuple<[
476
396
  Static.Const<RAngle>
477
397
  ], PickMapping>;
478
398
  interface OmitMapping extends Static.IMapping {
479
- output: this['input'] extends ['Omit', LAngle, infer Type extends Types.TSchema, Comma, infer Key extends Types.TSchema, RAngle] ? Types.TOmit<Type, Key> : never;
399
+ output: this['input'] extends ['Omit', LAngle, infer Type extends t.TSchema, Comma, infer Key extends t.TSchema, RAngle] ? t.TOmit<Type, Key> : never;
480
400
  }
481
401
  type Omit = Static.Tuple<[
482
402
  Static.Const<'Omit'>,
@@ -487,7 +407,7 @@ type Omit = Static.Tuple<[
487
407
  Static.Const<RAngle>
488
408
  ], OmitMapping>;
489
409
  interface ExcludeMapping extends Static.IMapping {
490
- output: this['input'] extends ['Exclude', LAngle, infer Type extends Types.TSchema, Comma, infer PropertyKey extends Types.TSchema, RAngle] ? Types.TExclude<Type, PropertyKey> : never;
410
+ output: this['input'] extends ['Exclude', LAngle, infer Type extends t.TSchema, Comma, infer PropertyKey extends t.TSchema, RAngle] ? t.TExclude<Type, PropertyKey> : never;
491
411
  }
492
412
  type Exclude = Static.Tuple<[
493
413
  Static.Const<'Exclude'>,
@@ -498,7 +418,7 @@ type Exclude = Static.Tuple<[
498
418
  Static.Const<RAngle>
499
419
  ], ExcludeMapping>;
500
420
  interface ExtractMapping extends Static.IMapping {
501
- output: this['input'] extends ['Extract', LAngle, infer Type extends Types.TSchema, Comma, infer PropertyKey extends Types.TSchema, RAngle] ? Types.TExtract<Type, PropertyKey> : never;
421
+ output: this['input'] extends ['Extract', LAngle, infer Type extends t.TSchema, Comma, infer PropertyKey extends t.TSchema, RAngle] ? t.TExtract<Type, PropertyKey> : never;
502
422
  }
503
423
  type Extract = Static.Tuple<[
504
424
  Static.Const<'Extract'>,
@@ -509,7 +429,7 @@ type Extract = Static.Tuple<[
509
429
  Static.Const<RAngle>
510
430
  ], ExtractMapping>;
511
431
  interface UppercaseMapping extends Static.IMapping {
512
- output: this['input'] extends ['Uppercase', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TUppercase<Type> : never;
432
+ output: this['input'] extends ['Uppercase', LAngle, infer Type extends t.TSchema, RAngle] ? t.TUppercase<Type> : never;
513
433
  }
514
434
  type Uppercase = Static.Tuple<[
515
435
  Static.Const<'Uppercase'>,
@@ -518,7 +438,7 @@ type Uppercase = Static.Tuple<[
518
438
  Static.Const<RAngle>
519
439
  ], UppercaseMapping>;
520
440
  interface LowercaseMapping extends Static.IMapping {
521
- output: this['input'] extends ['Lowercase', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TLowercase<Type> : never;
441
+ output: this['input'] extends ['Lowercase', LAngle, infer Type extends t.TSchema, RAngle] ? t.TLowercase<Type> : never;
522
442
  }
523
443
  type Lowercase = Static.Tuple<[
524
444
  Static.Const<'Lowercase'>,
@@ -527,7 +447,7 @@ type Lowercase = Static.Tuple<[
527
447
  Static.Const<RAngle>
528
448
  ], LowercaseMapping>;
529
449
  interface CapitalizeMapping extends Static.IMapping {
530
- output: this['input'] extends ['Capitalize', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TCapitalize<Type> : never;
450
+ output: this['input'] extends ['Capitalize', LAngle, infer Type extends t.TSchema, RAngle] ? t.TCapitalize<Type> : never;
531
451
  }
532
452
  type Capitalize = Static.Tuple<[
533
453
  Static.Const<'Capitalize'>,
@@ -536,7 +456,7 @@ type Capitalize = Static.Tuple<[
536
456
  Static.Const<RAngle>
537
457
  ], CapitalizeMapping>;
538
458
  interface UncapitalizeMapping extends Static.IMapping {
539
- output: this['input'] extends ['Uncapitalize', LAngle, infer Type extends Types.TSchema, RAngle] ? Types.TUncapitalize<Type> : never;
459
+ output: this['input'] extends ['Uncapitalize', LAngle, infer Type extends t.TSchema, RAngle] ? t.TUncapitalize<Type> : never;
540
460
  }
541
461
  type Uncapitalize = Static.Tuple<[
542
462
  Static.Const<'Uncapitalize'>,
@@ -544,12 +464,6 @@ type Uncapitalize = Static.Tuple<[
544
464
  Type,
545
465
  Static.Const<RAngle>
546
466
  ], UncapitalizeMapping>;
547
- type Date = Static.Const<'Date', Static.As<Types.TDate>>;
548
- type Uint8Array = Static.Const<'Uint8Array', Static.As<Types.TUint8Array>>;
549
- export type Main = Static.Union<[
550
- ModuleDeclaration,
551
- TypeAliasDeclaration,
552
- InterfaceDeclaration,
553
- Type
554
- ]>;
467
+ type Date = Static.Const<'Date', Static.As<t.TDate>>;
468
+ type Uint8Array = Static.Const<'Uint8Array', Static.As<t.TUint8Array>>;
555
469
  export {};
@@ -0,0 +1,33 @@
1
+ import * as Types from '../type/index.mjs';
2
+ import { Static } from '../parser/index.mjs';
3
+ import { Type } from './static.mjs';
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,30 @@
1
+ import * as Types from '../type/index.mjs';
2
+ import { Module } from './runtime.mjs';
3
+ /** Parses a TSchema type from TypeScript syntax but does not infer schematics */
4
+ // prettier-ignore
5
+ export function NoInfer(...args) {
6
+ const withContext = typeof args[0] === 'string' ? false : true;
7
+ const [context, code, options] = withContext ? [args[0], args[1], args[2] || {}] : [{}, args[0], args[1] || {}];
8
+ const type = Module.Parse('Type', code, context)[0];
9
+ return Types.KindGuard.IsSchema(type)
10
+ ? Types.CloneType(type, options)
11
+ : Types.Never(options);
12
+ }
13
+ /** Parses a TSchema type from TypeScript syntax */
14
+ export function Syntax(...args) {
15
+ return NoInfer.apply(null, args);
16
+ }
17
+ /**
18
+ * Parses a TSchema type from Syntax.
19
+ * @deprecated Use Syntax() function
20
+ */
21
+ export function Parse(...args) {
22
+ return NoInfer.apply(null, args);
23
+ }
24
+ /**
25
+ * Parses a TSchema from TypeScript Syntax
26
+ * @deprecated Use NoInfer() function
27
+ */
28
+ export function ParseOnly(...args) {
29
+ return NoInfer.apply(null, args);
30
+ }
@@ -1,7 +1,7 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
- import type { Ensure } from '../helpers/index.mjs';
3
2
  import type { TConstructor } from '../constructor/index.mjs';
4
3
  import { type TTuple } from '../tuple/index.mjs';
5
- export type TConstructorParameters<T extends TConstructor<TSchema[], TSchema>> = (Ensure<TTuple<T['parameters']>>);
4
+ import { type TNever } from '../never/index.mjs';
5
+ export type TConstructorParameters<Type extends TSchema> = (Type extends TConstructor<infer Parameters extends TSchema[], infer _InstanceType extends TSchema> ? TTuple<Parameters> : TNever);
6
6
  /** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
7
- export declare function ConstructorParameters<T extends TConstructor<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>;
7
+ export declare function ConstructorParameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TConstructorParameters<Type>;
@@ -1,5 +1,7 @@
1
1
  import { Tuple } from '../tuple/index.mjs';
2
+ import { Never } from '../never/index.mjs';
3
+ import * as KindGuard from '../guard/kind.mjs';
2
4
  /** `[JavaScript]` Extracts the ConstructorParameters from the given Constructor type */
3
5
  export function ConstructorParameters(schema, options) {
4
- return Tuple(schema.parameters, options);
6
+ return (KindGuard.IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options));
5
7
  }
@@ -1,5 +1,6 @@
1
- import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
- import type { TConstructor } from '../constructor/index.mjs';
3
- export type TInstanceType<T extends TConstructor<TSchema[], TSchema>> = T['returns'];
1
+ import { type TSchema, SchemaOptions } from '../schema/index.mjs';
2
+ import { type TConstructor } from '../constructor/index.mjs';
3
+ import { type TNever } from '../never/index.mjs';
4
+ export type TInstanceType<Type extends TSchema, Result extends TSchema = Type extends TConstructor<infer _Parameters extends TSchema[], infer InstanceType extends TSchema> ? InstanceType : TNever> = Result;
4
5
  /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
5
- export declare function InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>;
6
+ export declare function InstanceType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TInstanceType<Type>;
@@ -1,5 +1,7 @@
1
1
  import { CreateType } from '../create/type.mjs';
2
+ import { Never } from '../never/index.mjs';
3
+ import * as KindGuard from '../guard/kind.mjs';
2
4
  /** `[JavaScript]` Extracts the InstanceType from the given Constructor type */
3
5
  export function InstanceType(schema, options) {
4
- return CreateType(schema.returns, options);
6
+ return (KindGuard.IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options));
5
7
  }
@@ -1,7 +1,7 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TFunction } from '../function/index.mjs';
3
- import type { Ensure } from '../helpers/index.mjs';
4
3
  import { type TTuple } from '../tuple/index.mjs';
5
- export type TParameters<T extends TFunction> = Ensure<TTuple<T['parameters']>>;
4
+ import { type TNever } from '../never/index.mjs';
5
+ export type TParameters<Type extends TSchema> = (Type extends TFunction<infer Parameters extends TSchema[], infer _ReturnType extends TSchema> ? TTuple<Parameters> : TNever);
6
6
  /** `[JavaScript]` Extracts the Parameters from the given Function type */
7
- export declare function Parameters<T extends TFunction<TSchema[], TSchema>>(schema: T, options?: SchemaOptions): TParameters<T>;
7
+ export declare function Parameters<Type extends TSchema>(schema: Type, options?: SchemaOptions): TParameters<Type>;
@@ -1,5 +1,7 @@
1
1
  import { Tuple } from '../tuple/index.mjs';
2
+ import { Never } from '../never/index.mjs';
3
+ import * as KindGuard from '../guard/kind.mjs';
2
4
  /** `[JavaScript]` Extracts the Parameters from the given Function type */
3
5
  export function Parameters(schema, options) {
4
- return Tuple(schema.parameters, options);
6
+ return (KindGuard.IsFunction(schema) ? Tuple(schema.parameters, options) : Never());
5
7
  }
@@ -1,5 +1,6 @@
1
- import type { SchemaOptions } from '../schema/index.mjs';
2
- import type { TFunction } from '../function/index.mjs';
3
- export type TReturnType<T extends TFunction> = T['returns'];
1
+ import { type TSchema, type SchemaOptions } from '../schema/index.mjs';
2
+ import { type TFunction } from '../function/index.mjs';
3
+ import { type TNever } from '../never/index.mjs';
4
+ export type TReturnType<Type extends TSchema, Result extends TSchema = Type extends TFunction<infer _Parameters extends TSchema[], infer ReturnType extends TSchema> ? ReturnType : TNever> = Result;
4
5
  /** `[JavaScript]` Extracts the ReturnType from the given Function type */
5
- export declare function ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>;
6
+ export declare function ReturnType<Type extends TSchema>(schema: Type, options?: SchemaOptions): TReturnType<Type>;