@sinclair/typebox 0.34.28 → 0.34.29

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.
@@ -16,42 +16,23 @@ type SemiColon = ';';
16
16
  type SingleQuote = "'";
17
17
  type DoubleQuote = '"';
18
18
  type Tilde = '`';
19
- interface DelimitTailMapping<_ = unknown> extends Static.IMapping {
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 [_] ? [] : [
21
- ]);
19
+ type DelimitHeadReduce<Elements extends unknown[], Result extends unknown[] = []> = (Elements extends [infer Left extends unknown, ...infer Right extends unknown[]] ? Left extends [infer Element, infer _Delimiter] ? DelimitHeadReduce<Right, [...Result, Element]> : DelimitHeadReduce<Right, Result> : Result);
20
+ interface DelimitHeadMapping extends Static.IMapping {
21
+ output: this['input'] extends unknown[] ? DelimitHeadReduce<this['input']> : [];
22
22
  }
23
- type DelimitTail<T extends Static.IParser, _ extends Static.IParser> = Static.Union<[
24
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
25
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
26
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
27
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
28
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
29
- Static.Tuple<[_, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
30
- Static.Tuple<[_, T, _, T, _, T, _, Delimit<T, _>]>,
31
- Static.Tuple<[_, T, _, T, _, Delimit<T, _>]>,
32
- Static.Tuple<[_, T, _, Delimit<T, _>]>,
33
- Static.Tuple<[_, Delimit<T, _>]>,
34
- Static.Tuple<[_]>,
23
+ type DelimitHead<Element extends Static.IParser, Delimiter extends Static.IParser> = (Static.Array<Static.Tuple<[Element, Delimiter]>, DelimitHeadMapping>);
24
+ type DelimitTail<Element extends Static.IParser> = Static.Union<[
25
+ Static.Tuple<[Element]>,
35
26
  Static.Tuple<[]>
36
- ], DelimitTailMapping>;
27
+ ]>;
37
28
  interface DelimitMapping extends Static.IMapping {
38
- output: (this['input'] extends [infer Element extends unknown, infer Rest extends unknown[]] ? [Element, ...Rest] : []);
29
+ output: this['input'] extends [infer Left extends unknown[], infer Right extends unknown[]] ? [...Left, ...Right] : [];
39
30
  }
40
- type Delimit<Parser extends Static.IParser, Delimiter extends Static.IParser> = (Static.Union<[
41
- Static.Tuple<[Parser, DelimitTail<Parser, Delimiter>]>,
42
- Static.Tuple<[]>
43
- ], DelimitMapping>);
31
+ type Delimit<Element extends Static.IParser, Delimiter extends Static.IParser> = Static.Tuple<[
32
+ DelimitHead<Element, Delimiter>,
33
+ DelimitTail<Element>
34
+ ], DelimitMapping>;
44
35
  type Dereference<Context extends t.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : t.TRef<Ref>);
45
- interface GenericArgumentListMapping extends Static.IMapping {
46
- output: (this['input'] extends [infer Ident extends string, Comma, infer Rest extends unknown[]] ? [Ident, ...Rest] : this['input'] extends [infer Ident extends string, Comma] ? [Ident] : this['input'] extends [infer Ident extends string] ? [Ident] : [
47
- ]);
48
- }
49
- type GenericArgumentList = Static.Union<[
50
- Static.Tuple<[Static.Ident, Static.Const<Comma>, GenericArgumentList]>,
51
- Static.Tuple<[Static.Ident, Static.Const<Comma>]>,
52
- Static.Tuple<[Static.Ident]>,
53
- Static.Tuple<[]>
54
- ], GenericArgumentListMapping>;
55
36
  type GenericArgumentsContext<Args extends string[], Context extends t.TProperties, Result extends t.TProperties = {}> = (Args extends [...infer Left extends string[], infer Right extends string] ? GenericArgumentsContext<Left, Context, Result & {
56
37
  [_ in Right]: t.TArgument<Left['length']>;
57
38
  }> : t.Evaluate<Result & Context>);
@@ -60,7 +41,7 @@ interface GenericArgumentsMapping extends Static.IMapping {
60
41
  }
61
42
  type GenericArguments = Static.Tuple<[
62
43
  Static.Const<LAngle>,
63
- GenericArgumentList,
44
+ Delimit<Static.Ident, Static.Const<Comma>>,
64
45
  Static.Const<RAngle>
65
46
  ], GenericArgumentsMapping>;
66
47
  interface GenericReferenceMapping extends Static.IMapping {
@@ -243,7 +224,7 @@ type PropertyDelimiter = Static.Union<[
243
224
  Static.Tuple<[Static.Const<SemiColon>]>,
244
225
  Static.Tuple<[Static.Const<Newline>]>
245
226
  ]>;
246
- 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);
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>);
247
228
  interface PropertiesMapping extends Static.IMapping {
248
229
  output: this['input'] extends t.TProperties[] ? PropertiesReduce<this['input']> : never;
249
230
  }
@@ -16,42 +16,23 @@ type SemiColon = ';';
16
16
  type SingleQuote = "'";
17
17
  type DoubleQuote = '"';
18
18
  type Tilde = '`';
19
- interface DelimitTailMapping<_ = unknown> extends Static.IMapping {
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 [_] ? [] : [
21
- ]);
19
+ type DelimitHeadReduce<Elements extends unknown[], Result extends unknown[] = []> = (Elements extends [infer Left extends unknown, ...infer Right extends unknown[]] ? Left extends [infer Element, infer _Delimiter] ? DelimitHeadReduce<Right, [...Result, Element]> : DelimitHeadReduce<Right, Result> : Result);
20
+ interface DelimitHeadMapping extends Static.IMapping {
21
+ output: this['input'] extends unknown[] ? DelimitHeadReduce<this['input']> : [];
22
22
  }
23
- type DelimitTail<T extends Static.IParser, _ extends Static.IParser> = Static.Union<[
24
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
25
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
26
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
27
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
28
- Static.Tuple<[_, T, _, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
29
- Static.Tuple<[_, T, _, T, _, T, _, T, _, Delimit<T, _>]>,
30
- Static.Tuple<[_, T, _, T, _, T, _, Delimit<T, _>]>,
31
- Static.Tuple<[_, T, _, T, _, Delimit<T, _>]>,
32
- Static.Tuple<[_, T, _, Delimit<T, _>]>,
33
- Static.Tuple<[_, Delimit<T, _>]>,
34
- Static.Tuple<[_]>,
23
+ type DelimitHead<Element extends Static.IParser, Delimiter extends Static.IParser> = (Static.Array<Static.Tuple<[Element, Delimiter]>, DelimitHeadMapping>);
24
+ type DelimitTail<Element extends Static.IParser> = Static.Union<[
25
+ Static.Tuple<[Element]>,
35
26
  Static.Tuple<[]>
36
- ], DelimitTailMapping>;
27
+ ]>;
37
28
  interface DelimitMapping extends Static.IMapping {
38
- output: (this['input'] extends [infer Element extends unknown, infer Rest extends unknown[]] ? [Element, ...Rest] : []);
29
+ output: this['input'] extends [infer Left extends unknown[], infer Right extends unknown[]] ? [...Left, ...Right] : [];
39
30
  }
40
- type Delimit<Parser extends Static.IParser, Delimiter extends Static.IParser> = (Static.Union<[
41
- Static.Tuple<[Parser, DelimitTail<Parser, Delimiter>]>,
42
- Static.Tuple<[]>
43
- ], DelimitMapping>);
31
+ type Delimit<Element extends Static.IParser, Delimiter extends Static.IParser> = Static.Tuple<[
32
+ DelimitHead<Element, Delimiter>,
33
+ DelimitTail<Element>
34
+ ], DelimitMapping>;
44
35
  type Dereference<Context extends t.TProperties, Ref extends string> = (Ref extends keyof Context ? Context[Ref] : t.TRef<Ref>);
45
- interface GenericArgumentListMapping extends Static.IMapping {
46
- output: (this['input'] extends [infer Ident extends string, Comma, infer Rest extends unknown[]] ? [Ident, ...Rest] : this['input'] extends [infer Ident extends string, Comma] ? [Ident] : this['input'] extends [infer Ident extends string] ? [Ident] : [
47
- ]);
48
- }
49
- type GenericArgumentList = Static.Union<[
50
- Static.Tuple<[Static.Ident, Static.Const<Comma>, GenericArgumentList]>,
51
- Static.Tuple<[Static.Ident, Static.Const<Comma>]>,
52
- Static.Tuple<[Static.Ident]>,
53
- Static.Tuple<[]>
54
- ], GenericArgumentListMapping>;
55
36
  type GenericArgumentsContext<Args extends string[], Context extends t.TProperties, Result extends t.TProperties = {}> = (Args extends [...infer Left extends string[], infer Right extends string] ? GenericArgumentsContext<Left, Context, Result & {
56
37
  [_ in Right]: t.TArgument<Left['length']>;
57
38
  }> : t.Evaluate<Result & Context>);
@@ -60,7 +41,7 @@ interface GenericArgumentsMapping extends Static.IMapping {
60
41
  }
61
42
  type GenericArguments = Static.Tuple<[
62
43
  Static.Const<LAngle>,
63
- GenericArgumentList,
44
+ Delimit<Static.Ident, Static.Const<Comma>>,
64
45
  Static.Const<RAngle>
65
46
  ], GenericArgumentsMapping>;
66
47
  interface GenericReferenceMapping extends Static.IMapping {
@@ -243,7 +224,7 @@ type PropertyDelimiter = Static.Union<[
243
224
  Static.Tuple<[Static.Const<SemiColon>]>,
244
225
  Static.Tuple<[Static.Const<Newline>]>
245
226
  ]>;
246
- 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);
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>);
247
228
  interface PropertiesMapping extends Static.IMapping {
248
229
  output: this['input'] extends t.TProperties[] ? PropertiesReduce<this['input']> : never;
249
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.34.28",
3
+ "version": "0.34.29",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",