@sinclair/typebox 0.34.29 → 0.34.30

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.
@@ -39,18 +39,20 @@ type GenericArgumentsContext<Args extends string[], Context extends t.TPropertie
39
39
  interface GenericArgumentsMapping extends Static.IMapping {
40
40
  output: this['input'] extends [LAngle, infer Args extends string[], RAngle] ? this['context'] extends infer Context extends t.TProperties ? GenericArgumentsContext<Args, Context> : never : never;
41
41
  }
42
+ type GenericArgumentsList = Delimit<Static.Ident, Static.Const<Comma>>;
42
43
  type GenericArguments = Static.Tuple<[
43
44
  Static.Const<LAngle>,
44
- Delimit<Static.Ident, Static.Const<Comma>>,
45
+ GenericArgumentsList,
45
46
  Static.Const<RAngle>
46
47
  ], GenericArgumentsMapping>;
47
48
  interface GenericReferenceMapping extends Static.IMapping {
48
49
  output: this['context'] extends t.TProperties ? this['input'] extends [infer Reference extends string, LAngle, infer Args extends t.TSchema[], RAngle] ? t.TInstantiate<Dereference<this['context'], Reference>, Args> : never : never;
49
50
  }
51
+ type GenericReferenceParameters = Delimit<Type, Static.Const<Comma>>;
50
52
  type GenericReference = Static.Tuple<[
51
53
  Static.Ident,
52
54
  Static.Const<LAngle>,
53
- Elements,
55
+ GenericReferenceParameters,
54
56
  Static.Const<RAngle>
55
57
  ], GenericReferenceMapping>;
56
58
  interface ReferenceMapping extends Static.IMapping {
@@ -58,13 +60,13 @@ interface ReferenceMapping extends Static.IMapping {
58
60
  }
59
61
  type Reference = Static.Ident<ReferenceMapping>;
60
62
  interface LiteralBooleanMapping extends Static.IMapping {
61
- output: this['input'] extends `${infer S extends boolean}` ? t.TLiteral<S> : never;
63
+ output: this['input'] extends `${infer Value extends boolean}` ? t.TLiteral<Value> : never;
62
64
  }
63
65
  interface LiteralNumberMapping extends Static.IMapping {
64
- output: this['input'] extends `${infer S extends number}` ? t.TLiteral<S> : never;
66
+ output: this['input'] extends `${infer Value extends number}` ? t.TLiteral<Value> : never;
65
67
  }
66
68
  interface LiteralStringMapping extends Static.IMapping {
67
- output: this['input'] extends `${infer S extends string}` ? t.TLiteral<S> : never;
69
+ output: this['input'] extends `${infer Value extends string}` ? t.TLiteral<Value> : never;
68
70
  }
69
71
  type Literal = Static.Union<[
70
72
  Static.Union<[Static.Const<'true'>, Static.Const<'false'>], LiteralBooleanMapping>,
@@ -72,17 +74,17 @@ type Literal = Static.Union<[
72
74
  Static.String<[DoubleQuote, SingleQuote, Tilde], LiteralStringMapping>
73
75
  ]>;
74
76
  type Keyword = Static.Union<[
75
- Static.Const<'any', Static.As<t.TAny>>,
76
- Static.Const<'bigint', Static.As<t.TBigInt>>,
77
+ Static.Const<'string', Static.As<t.TString>>,
78
+ Static.Const<'number', Static.As<t.TNumber>>,
77
79
  Static.Const<'boolean', Static.As<t.TBoolean>>,
80
+ Static.Const<'undefined', Static.As<t.TUndefined>>,
81
+ Static.Const<'null', Static.As<t.TNull>>,
78
82
  Static.Const<'integer', Static.As<t.TInteger>>,
83
+ Static.Const<'bigint', Static.As<t.TBigInt>>,
84
+ Static.Const<'unknown', Static.As<t.TUnknown>>,
85
+ Static.Const<'any', Static.As<t.TAny>>,
79
86
  Static.Const<'never', Static.As<t.TNever>>,
80
- Static.Const<'null', Static.As<t.TNull>>,
81
- Static.Const<'number', Static.As<t.TNumber>>,
82
- Static.Const<'string', Static.As<t.TString>>,
83
87
  Static.Const<'symbol', Static.As<t.TSymbol>>,
84
- Static.Const<'undefined', Static.As<t.TUndefined>>,
85
- Static.Const<'unknown', Static.As<t.TUnknown>>,
86
88
  Static.Const<'void', Static.As<t.TVoid>>
87
89
  ]>;
88
90
  interface KeyOfMapping extends Static.IMapping {
@@ -92,15 +94,14 @@ type KeyOf = Static.Union<[
92
94
  Static.Tuple<[Static.Const<'keyof'>]>,
93
95
  Static.Tuple<[]>
94
96
  ], KeyOfMapping>;
97
+ type IndexArrayReduce<Values extends unknown[], Result extends unknown[] = []> = (Values extends [infer Left extends unknown, ...infer Right extends unknown[]] ? Left extends [LBracket, infer Type extends t.TSchema, RBracket] ? IndexArrayReduce<Right, [...Result, [Type]]> : IndexArrayReduce<Right, [...Result, []]> : Result);
95
98
  interface IndexArrayMapping extends Static.IMapping {
96
- 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] : [
97
- ]);
99
+ output: this['input'] extends unknown[] ? IndexArrayReduce<this['input']> : [];
98
100
  }
99
- type IndexArray = Static.Union<[
100
- Static.Tuple<[Static.Const<LBracket>, Type, Static.Const<RBracket>, IndexArray]>,
101
- Static.Tuple<[Static.Const<LBracket>, Static.Const<RBracket>, IndexArray]>,
102
- Static.Tuple<[]>
103
- ], IndexArrayMapping>;
101
+ type IndexArray = Static.Array<Static.Union<[
102
+ Static.Tuple<[Static.Const<LBracket>, Type, Static.Const<RBracket>]>,
103
+ Static.Tuple<[Static.Const<LBracket>, Static.Const<RBracket>]>
104
+ ]>, IndexArrayMapping>;
104
105
  interface ExtendsMapping extends Static.IMapping {
105
106
  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] : [];
106
107
  }
@@ -109,50 +110,42 @@ type Extends = Static.Union<[
109
110
  Static.Tuple<[]>
110
111
  ], ExtendsMapping>;
111
112
  interface BaseMapping extends Static.IMapping {
112
- output: (this['input'] extends [LParen, infer Type extends t.TSchema, RParen] ? Type : this['input'] extends [infer Type extends t.TSchema] ? Type : never);
113
+ output: (this['input'] extends [LParen, infer Type extends t.TSchema, RParen] ? Type : this['input'] extends infer Type extends t.TSchema ? Type : never);
113
114
  }
114
115
  type Base = Static.Union<[
115
- Static.Tuple<[
116
- Static.Const<LParen>,
117
- Type,
118
- Static.Const<RParen>
119
- ]>,
120
- Static.Tuple<[
121
- Static.Union<[
122
- Literal,
123
- Keyword,
124
- Object,
125
- Tuple,
126
- Function,
127
- Constructor,
128
- Mapped,
129
- AsyncIterator,
130
- Iterator,
131
- ConstructorParameters,
132
- FunctionParameters,
133
- Argument,
134
- InstanceType,
135
- ReturnType,
136
- Awaited,
137
- Array,
138
- Record,
139
- Promise,
140
- Partial,
141
- Required,
142
- Pick,
143
- Omit,
144
- Exclude,
145
- Extract,
146
- Lowercase,
147
- Uppercase,
148
- Capitalize,
149
- Uncapitalize,
150
- Date,
151
- Uint8Array,
152
- GenericReference,
153
- Reference
154
- ]>
155
- ]>
116
+ Static.Tuple<[Static.Const<LParen>, Type, Static.Const<RParen>]>,
117
+ Keyword,
118
+ Object,
119
+ Tuple,
120
+ Literal,
121
+ Function,
122
+ Constructor,
123
+ Mapped,
124
+ AsyncIterator,
125
+ Iterator,
126
+ ConstructorParameters,
127
+ FunctionParameters,
128
+ Argument,
129
+ InstanceType,
130
+ ReturnType,
131
+ Awaited,
132
+ Array,
133
+ Record,
134
+ Promise,
135
+ Partial,
136
+ Required,
137
+ Pick,
138
+ Omit,
139
+ Exclude,
140
+ Extract,
141
+ Lowercase,
142
+ Uppercase,
143
+ Capitalize,
144
+ Uncapitalize,
145
+ Date,
146
+ Uint8Array,
147
+ GenericReference,
148
+ Reference
156
149
  ], BaseMapping>;
157
150
  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);
158
151
  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);
@@ -224,26 +217,23 @@ type PropertyDelimiter = Static.Union<[
224
217
  Static.Tuple<[Static.Const<SemiColon>]>,
225
218
  Static.Tuple<[Static.Const<Newline>]>
226
219
  ]>;
227
- type PropertiesReduce<PropertiesArray extends t.TProperties[], Result extends t.TProperties = {}> = (PropertiesArray extends [infer Left extends t.TProperties, ...infer Right extends t.TProperties[]] ? PropertiesReduce<Right, Result & Left> : t.Evaluate<Result>);
228
- interface PropertiesMapping extends Static.IMapping {
229
- output: this['input'] extends t.TProperties[] ? PropertiesReduce<this['input']> : never;
230
- }
231
- type Properties = Static.Union<[Delimit<Property, PropertyDelimiter>], PropertiesMapping>;
220
+ type PropertyList = Delimit<Property, PropertyDelimiter>;
221
+ type ObjectReduce<PropertiesList extends t.TProperties[], Result extends t.TProperties = {}> = (PropertiesList extends [infer Left extends t.TProperties, ...infer Right extends t.TProperties[]] ? ObjectReduce<Right, Result & Left> : t.Evaluate<Result>);
232
222
  interface ObjectMapping extends Static.IMapping {
233
- output: this['input'] extends [unknown, infer Properties extends t.TProperties, unknown] ? t.TObject<Properties> : never;
223
+ output: this['input'] extends [LBrace, infer PropertyList extends t.TProperties[], RBrace] ? t.TObject<ObjectReduce<PropertyList>> : never;
234
224
  }
235
225
  type Object = Static.Tuple<[
236
226
  Static.Const<LBrace>,
237
- Properties,
227
+ PropertyList,
238
228
  Static.Const<RBrace>
239
229
  ], ObjectMapping>;
240
- type Elements = Delimit<Type, Static.Const<Comma>>;
230
+ type ElementList = Delimit<Type, Static.Const<Comma>>;
241
231
  interface TupleMapping extends Static.IMapping {
242
- output: this['input'] extends [unknown, infer Elements extends t.TSchema[], unknown] ? t.TTuple<Elements> : never;
232
+ output: this['input'] extends [unknown, infer ElementList extends t.TSchema[], unknown] ? t.TTuple<ElementList> : never;
243
233
  }
244
234
  type Tuple = Static.Tuple<[
245
235
  Static.Const<LBracket>,
246
- Elements,
236
+ ElementList,
247
237
  Static.Const<RBracket>
248
238
  ], TupleMapping>;
249
239
  interface ParameterMapping extends Static.IMapping {
@@ -254,24 +244,24 @@ type Parameter = Static.Tuple<[
254
244
  Static.Const<Colon>,
255
245
  Type
256
246
  ], ParameterMapping>;
257
- type Parameters = Delimit<Parameter, Static.Const<Comma>>;
247
+ type ParameterList = Delimit<Parameter, Static.Const<Comma>>;
258
248
  interface FunctionMapping extends Static.IMapping {
259
- output: this['input'] extends [LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer ReturnType extends t.TSchema] ? t.TFunction<Parameters, ReturnType> : never;
249
+ output: this['input'] extends [LParen, infer ParameterList extends t.TSchema[], RParen, '=>', infer ReturnType extends t.TSchema] ? t.TFunction<ParameterList, ReturnType> : never;
260
250
  }
261
251
  type Function = Static.Tuple<[
262
252
  Static.Const<LParen>,
263
- Parameters,
253
+ ParameterList,
264
254
  Static.Const<RParen>,
265
255
  Static.Const<'=>'>,
266
256
  Type
267
257
  ], FunctionMapping>;
268
258
  interface ConstructorMapping extends Static.IMapping {
269
- output: this['input'] extends ['new', LParen, infer Parameters extends t.TSchema[], RParen, '=>', infer InstanceType extends t.TSchema] ? t.TConstructor<Parameters, InstanceType> : never;
259
+ output: this['input'] extends ['new', LParen, infer ParameterList extends t.TSchema[], RParen, '=>', infer InstanceType extends t.TSchema] ? t.TConstructor<ParameterList, InstanceType> : never;
270
260
  }
271
261
  type Constructor = Static.Tuple<[
272
262
  Static.Const<'new'>,
273
263
  Static.Const<LParen>,
274
- Parameters,
264
+ ParameterList,
275
265
  Static.Const<RParen>,
276
266
  Static.Const<'=>'>,
277
267
  Type
@@ -1,12 +1,12 @@
1
1
  import { Runtime } from '../parser/index.mjs';
2
2
  import * as t from '../type/index.mjs';
3
3
  export declare const Module: Runtime.Module<{
4
- GenericArgumentList: Runtime.IUnion<unknown[]>;
4
+ GenericArgumentsList: Runtime.ITuple<unknown[]>;
5
5
  GenericArguments: Runtime.ITuple<t.TProperties>;
6
6
  Literal: Runtime.IUnion<t.TLiteral<string> | t.TLiteral<number> | t.TLiteral<boolean>>;
7
7
  Keyword: Runtime.IUnion<t.TAny | t.TBoolean | t.TBigInt | t.TNever | t.TString | t.TNumber | t.TInteger | t.TNull | t.TSymbol | t.TUndefined | t.TUnknown | t.TVoid>;
8
8
  KeyOf: Runtime.IUnion<boolean>;
9
- IndexArray: Runtime.IUnion<unknown[]>;
9
+ IndexArray: Runtime.IArray<unknown[]>;
10
10
  Extends: Runtime.IUnion<unknown[]>;
11
11
  Base: Runtime.IUnion<unknown>;
12
12
  Factor: Runtime.ITuple<t.TSchema>;
@@ -22,13 +22,13 @@ export declare const Module: Runtime.Module<{
22
22
  [x: string]: t.TSchema;
23
23
  }>;
24
24
  PropertyDelimiter: Runtime.IUnion<[","] | [",", "\n"] | [";"] | [";", "\n"] | ["\n"]>;
25
- Properties: Runtime.IUnion<t.TProperties>;
25
+ PropertyList: Runtime.ITuple<unknown[]>;
26
26
  Object: Runtime.ITuple<t.TObject<t.TProperties>>;
27
- Elements: Runtime.IUnion<unknown[]>;
27
+ ElementList: Runtime.ITuple<unknown[]>;
28
28
  Tuple: Runtime.ITuple<t.TTuple<t.TSchema[]>>;
29
29
  Parameter: Runtime.ITuple<t.TSchema>;
30
+ ParameterList: Runtime.ITuple<unknown[]>;
30
31
  Function: Runtime.ITuple<t.TFunction<t.TSchema[], t.TSchema>>;
31
- Parameters: Runtime.IUnion<unknown[]>;
32
32
  Constructor: Runtime.ITuple<t.TConstructor<t.TSchema[], t.TSchema>>;
33
33
  Mapped: Runtime.ITuple<t.TLiteral<"Mapped types not supported">>;
34
34
  AsyncIterator: Runtime.ITuple<t.TAsyncIterator<t.TSchema>>;
@@ -54,6 +54,7 @@ export declare const Module: Runtime.Module<{
54
54
  Uncapitalize: Runtime.ITuple<t.TSchema>;
55
55
  Date: Runtime.IConst<t.TDate>;
56
56
  Uint8Array: Runtime.IConst<t.TUint8Array>;
57
+ GenericReferenceParameters: Runtime.ITuple<unknown[]>;
57
58
  GenericReference: Runtime.ITuple<t.TSchema>;
58
59
  Reference: Runtime.IIdent<t.TSchema>;
59
60
  }>;