@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.
Files changed (141) hide show
  1. package/build/cjs/compiler/compiler.js +5 -0
  2. package/build/cjs/errors/errors.js +3 -0
  3. package/build/cjs/index.d.ts +3 -0
  4. package/build/cjs/index.js +3 -0
  5. package/build/cjs/syntax/index.d.ts +1 -1
  6. package/build/cjs/syntax/index.js +1 -1
  7. package/build/cjs/syntax/runtime.d.ts +40 -54
  8. package/build/cjs/syntax/runtime.js +91 -203
  9. package/build/cjs/syntax/static.d.ts +80 -146
  10. package/build/cjs/syntax/syntax.d.ts +33 -0
  11. package/build/cjs/syntax/syntax.js +37 -0
  12. package/build/cjs/type/argument/argument.d.ts +9 -0
  13. package/build/cjs/type/argument/argument.js +10 -0
  14. package/build/cjs/type/argument/index.d.ts +1 -0
  15. package/build/cjs/type/argument/index.js +18 -0
  16. package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +3 -3
  17. package/build/cjs/type/constructor-parameters/constructor-parameters.js +3 -1
  18. package/build/cjs/type/guard/kind.d.ts +9 -6
  19. package/build/cjs/type/guard/kind.js +6 -0
  20. package/build/cjs/type/guard/type.d.ts +9 -6
  21. package/build/cjs/type/guard/type.js +9 -0
  22. package/build/cjs/type/index.d.ts +2 -0
  23. package/build/cjs/type/index.js +2 -0
  24. package/build/cjs/type/instance-type/instance-type.d.ts +5 -4
  25. package/build/cjs/type/instance-type/instance-type.js +3 -1
  26. package/build/cjs/type/instantiate/index.d.ts +1 -0
  27. package/build/cjs/type/instantiate/index.js +18 -0
  28. package/build/cjs/type/instantiate/instantiate.d.ts +25 -0
  29. package/build/cjs/type/instantiate/instantiate.js +32 -0
  30. package/build/cjs/type/parameters/parameters.d.ts +3 -3
  31. package/build/cjs/type/parameters/parameters.js +3 -1
  32. package/build/cjs/type/record/record.d.ts +16 -1
  33. package/build/cjs/type/record/record.js +53 -23
  34. package/build/cjs/type/remap/index.d.ts +1 -0
  35. package/build/cjs/type/remap/index.js +18 -0
  36. package/build/cjs/type/remap/remap.d.ts +19 -0
  37. package/build/cjs/type/remap/remap.js +35 -0
  38. package/build/cjs/type/return-type/return-type.d.ts +5 -4
  39. package/build/cjs/type/return-type/return-type.js +3 -1
  40. package/build/cjs/type/type/javascript.d.ts +10 -4
  41. package/build/cjs/type/type/javascript.js +44 -34
  42. package/build/cjs/type/type/type.d.ts +3 -0
  43. package/build/cjs/type/type/type.js +123 -117
  44. package/build/cjs/value/check/check.js +5 -0
  45. package/build/cjs/value/create/create.js +5 -0
  46. package/build/esm/compiler/compiler.mjs +5 -0
  47. package/build/esm/errors/errors.mjs +3 -0
  48. package/build/esm/index.d.mts +3 -0
  49. package/build/esm/index.mjs +3 -0
  50. package/build/esm/syntax/index.d.mts +1 -1
  51. package/build/esm/syntax/index.mjs +1 -1
  52. package/build/esm/syntax/runtime.d.mts +40 -54
  53. package/build/esm/syntax/runtime.mjs +91 -203
  54. package/build/esm/syntax/static.d.mts +80 -146
  55. package/build/esm/syntax/syntax.d.mts +33 -0
  56. package/build/esm/syntax/syntax.mjs +30 -0
  57. package/build/esm/type/argument/argument.d.mts +9 -0
  58. package/build/esm/type/argument/argument.mjs +6 -0
  59. package/build/esm/type/argument/index.d.mts +1 -0
  60. package/build/esm/type/argument/index.mjs +1 -0
  61. package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +3 -3
  62. package/build/esm/type/constructor-parameters/constructor-parameters.mjs +3 -1
  63. package/build/esm/type/guard/kind.d.mts +9 -6
  64. package/build/esm/type/guard/kind.mjs +5 -0
  65. package/build/esm/type/guard/type.d.mts +9 -6
  66. package/build/esm/type/guard/type.mjs +8 -0
  67. package/build/esm/type/index.d.mts +2 -0
  68. package/build/esm/type/index.mjs +2 -0
  69. package/build/esm/type/instance-type/instance-type.d.mts +5 -4
  70. package/build/esm/type/instance-type/instance-type.mjs +3 -1
  71. package/build/esm/type/instantiate/index.d.mts +1 -0
  72. package/build/esm/type/instantiate/index.mjs +1 -0
  73. package/build/esm/type/instantiate/instantiate.d.mts +25 -0
  74. package/build/esm/type/instantiate/instantiate.mjs +28 -0
  75. package/build/esm/type/parameters/parameters.d.mts +3 -3
  76. package/build/esm/type/parameters/parameters.mjs +3 -1
  77. package/build/esm/type/record/record.d.mts +16 -1
  78. package/build/esm/type/record/record.mjs +35 -8
  79. package/build/esm/type/remap/index.d.mts +1 -0
  80. package/build/esm/type/remap/index.mjs +1 -0
  81. package/build/esm/type/remap/remap.d.mts +19 -0
  82. package/build/esm/type/remap/remap.mjs +31 -0
  83. package/build/esm/type/return-type/return-type.d.mts +5 -4
  84. package/build/esm/type/return-type/return-type.mjs +3 -1
  85. package/build/esm/type/type/javascript.d.mts +10 -4
  86. package/build/esm/type/type/javascript.mjs +10 -0
  87. package/build/esm/type/type/type.d.mts +3 -0
  88. package/build/esm/type/type/type.mjs +3 -0
  89. package/build/esm/value/check/check.mjs +5 -0
  90. package/build/esm/value/create/create.mjs +5 -0
  91. package/package.json +11 -1
  92. package/parser/package.json +4 -0
  93. package/readme.md +107 -184
  94. package/build/cjs/syntax/parse.d.ts +0 -15
  95. package/build/cjs/syntax/parse.js +0 -19
  96. package/build/esm/syntax/parse.d.mts +0 -15
  97. package/build/esm/syntax/parse.mjs +0 -14
  98. /package/build/cjs/{syntax/parsebox → parser}/index.d.ts +0 -0
  99. /package/build/cjs/{syntax/parsebox → parser}/index.js +0 -0
  100. /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.d.ts +0 -0
  101. /package/build/cjs/{syntax/parsebox → parser}/runtime/guard.js +0 -0
  102. /package/build/cjs/{syntax/parsebox → parser}/runtime/index.d.ts +0 -0
  103. /package/build/cjs/{syntax/parsebox → parser}/runtime/index.js +0 -0
  104. /package/build/cjs/{syntax/parsebox → parser}/runtime/module.d.ts +0 -0
  105. /package/build/cjs/{syntax/parsebox → parser}/runtime/module.js +0 -0
  106. /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.d.ts +0 -0
  107. /package/build/cjs/{syntax/parsebox → parser}/runtime/parse.js +0 -0
  108. /package/build/cjs/{syntax/parsebox → parser}/runtime/token.d.ts +0 -0
  109. /package/build/cjs/{syntax/parsebox → parser}/runtime/token.js +0 -0
  110. /package/build/cjs/{syntax/parsebox → parser}/runtime/types.d.ts +0 -0
  111. /package/build/cjs/{syntax/parsebox → parser}/runtime/types.js +0 -0
  112. /package/build/cjs/{syntax/parsebox → parser}/static/index.d.ts +0 -0
  113. /package/build/cjs/{syntax/parsebox → parser}/static/index.js +0 -0
  114. /package/build/cjs/{syntax/parsebox → parser}/static/parse.d.ts +0 -0
  115. /package/build/cjs/{syntax/parsebox → parser}/static/parse.js +0 -0
  116. /package/build/cjs/{syntax/parsebox → parser}/static/token.d.ts +0 -0
  117. /package/build/cjs/{syntax/parsebox → parser}/static/token.js +0 -0
  118. /package/build/cjs/{syntax/parsebox → parser}/static/types.d.ts +0 -0
  119. /package/build/cjs/{syntax/parsebox → parser}/static/types.js +0 -0
  120. /package/build/esm/{syntax/parsebox → parser}/index.d.mts +0 -0
  121. /package/build/esm/{syntax/parsebox → parser}/index.mjs +0 -0
  122. /package/build/esm/{syntax/parsebox → parser}/runtime/guard.d.mts +0 -0
  123. /package/build/esm/{syntax/parsebox → parser}/runtime/guard.mjs +0 -0
  124. /package/build/esm/{syntax/parsebox → parser}/runtime/index.d.mts +0 -0
  125. /package/build/esm/{syntax/parsebox → parser}/runtime/index.mjs +0 -0
  126. /package/build/esm/{syntax/parsebox → parser}/runtime/module.d.mts +0 -0
  127. /package/build/esm/{syntax/parsebox → parser}/runtime/module.mjs +0 -0
  128. /package/build/esm/{syntax/parsebox → parser}/runtime/parse.d.mts +0 -0
  129. /package/build/esm/{syntax/parsebox → parser}/runtime/parse.mjs +0 -0
  130. /package/build/esm/{syntax/parsebox → parser}/runtime/token.d.mts +0 -0
  131. /package/build/esm/{syntax/parsebox → parser}/runtime/token.mjs +0 -0
  132. /package/build/esm/{syntax/parsebox → parser}/runtime/types.d.mts +0 -0
  133. /package/build/esm/{syntax/parsebox → parser}/runtime/types.mjs +0 -0
  134. /package/build/esm/{syntax/parsebox → parser}/static/index.d.mts +0 -0
  135. /package/build/esm/{syntax/parsebox → parser}/static/index.mjs +0 -0
  136. /package/build/esm/{syntax/parsebox → parser}/static/parse.d.mts +0 -0
  137. /package/build/esm/{syntax/parsebox → parser}/static/parse.mjs +0 -0
  138. /package/build/esm/{syntax/parsebox → parser}/static/token.d.mts +0 -0
  139. /package/build/esm/{syntax/parsebox → parser}/static/token.mjs +0 -0
  140. /package/build/esm/{syntax/parsebox → parser}/static/types.d.mts +0 -0
  141. /package/build/esm/{syntax/parsebox → parser}/static/types.mjs +0 -0
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Module = void 0;
5
- const index_1 = require("./parsebox/index");
6
- const Types = require("../type/index");
5
+ const index_1 = require("../parser/index");
6
+ const t = require("../type/index");
7
7
  // ------------------------------------------------------------------
8
8
  // Tokens
9
9
  // ------------------------------------------------------------------
@@ -34,159 +34,54 @@ function DestructureRight(values) {
34
34
  : [values, undefined];
35
35
  }
36
36
  // ------------------------------------------------------------------
37
- // Deref
37
+ // Dereference
38
38
  // ------------------------------------------------------------------
39
- const Deref = (context, key) => {
40
- return key in context ? context[key] : Types.Ref(key);
39
+ const Dereference = (context, key) => {
40
+ return key in context ? context[key] : t.Ref(key);
41
41
  };
42
42
  // ------------------------------------------------------------------
43
- // ExportModifier
43
+ // GenericReference
44
44
  // ------------------------------------------------------------------
45
- // prettier-ignore
46
- const ExportModifierMapping = (values) => {
47
- return values.length === 1;
48
- };
49
- // prettier-ignore
50
- const ExportModifier = index_1.Runtime.Union([
51
- index_1.Runtime.Tuple([index_1.Runtime.Const('export')]), index_1.Runtime.Tuple([])
52
- ], ExportModifierMapping);
53
- // ------------------------------------------------------------------
54
- // TypeAliasDeclaration
55
- // ------------------------------------------------------------------
56
- // prettier-ignore
57
- const TypeAliasDeclarationMapping = (_Export, _Keyword, Ident, _Equals, Type) => {
58
- return { [Ident]: Type };
59
- };
60
- // prettier-ignore
61
- const TypeAliasDeclaration = index_1.Runtime.Tuple([
62
- index_1.Runtime.Ref('ExportModifier'),
63
- index_1.Runtime.Const('type'),
64
- index_1.Runtime.Ident(),
65
- index_1.Runtime.Const(Equals),
66
- index_1.Runtime.Ref('Type')
67
- ], value => TypeAliasDeclarationMapping(...value));
68
- // ------------------------------------------------------------------
69
- // HeritageList
70
- // ------------------------------------------------------------------
71
- // prettier-ignore (note, heritage list should disallow trailing comma)
72
- const HeritageListDelimiter = index_1.Runtime.Union([index_1.Runtime.Tuple([index_1.Runtime.Const(Comma), index_1.Runtime.Const(Newline)]), index_1.Runtime.Tuple([index_1.Runtime.Const(Comma)])]);
73
- // prettier-ignore
74
- const HeritageListMapping = (values, context) => {
75
- return (values.length === 3 ? [Deref(context, values[0]), ...values[2]] :
76
- values.length === 1 ? [Deref(context, values[0])] :
77
- []);
78
- };
79
- // prettier-ignore
80
- const HeritageList = index_1.Runtime.Union([
81
- index_1.Runtime.Tuple([index_1.Runtime.Ident(), HeritageListDelimiter, index_1.Runtime.Ref('HeritageList')]),
82
- index_1.Runtime.Tuple([index_1.Runtime.Ident()]),
83
- index_1.Runtime.Tuple([])
84
- ], HeritageListMapping);
85
- // ------------------------------------------------------------------
86
- // Heritage
87
- // ------------------------------------------------------------------
88
- // prettier-ignore
89
- const HeritageMapping = (values) => {
90
- return (values.length === 2 ? values[1] : []);
91
- };
92
- // prettier-ignore
93
- const Heritage = index_1.Runtime.Union([
94
- index_1.Runtime.Tuple([index_1.Runtime.Const('extends'), index_1.Runtime.Ref('HeritageList')]),
95
- index_1.Runtime.Tuple([])
96
- ], HeritageMapping);
97
- // ------------------------------------------------------------------
98
- // InterfaceDeclaration
99
- // ------------------------------------------------------------------
100
- // prettier-ignore
101
- const InterfaceDeclarationMapping = (_0, _1, Ident, Heritage, _4, Properties, _6) => {
102
- return { [Ident]: Types.Intersect([...Heritage, Types.Object(Properties)]) };
103
- };
104
- // prettier-ignore
105
- const InterfaceDeclaration = index_1.Runtime.Tuple([
106
- index_1.Runtime.Ref('ExportModifier'),
107
- index_1.Runtime.Const('interface'),
108
- index_1.Runtime.Ident(),
109
- index_1.Runtime.Ref('Heritage'),
110
- index_1.Runtime.Const(LBrace),
111
- index_1.Runtime.Ref('Properties'),
112
- index_1.Runtime.Const(RBrace),
113
- ], values => InterfaceDeclarationMapping(...values));
114
- // ------------------------------------------------------------------
115
- // ModuleType
116
- // ------------------------------------------------------------------
117
- // prettier-ignore
118
- const ModuleType = index_1.Runtime.Union([
119
- index_1.Runtime.Ref('InterfaceDeclaration'),
120
- index_1.Runtime.Ref('TypeAliasDeclaration')
121
- ]);
122
- // ------------------------------------------------------------------
123
- // ModuleProperties
124
- // ------------------------------------------------------------------
125
- // prettier-ignore
126
- const ModulePropertiesDelimiter = index_1.Runtime.Union([
127
- index_1.Runtime.Tuple([index_1.Runtime.Const(SemiColon), index_1.Runtime.Const(Newline)]),
128
- index_1.Runtime.Tuple([index_1.Runtime.Const(SemiColon)]),
129
- index_1.Runtime.Tuple([index_1.Runtime.Const(Newline)]),
130
- ]);
131
- // prettier-ignore
132
- const ModulePropertiesMapping = (values) => {
133
- return (values.length === 3 ? { ...values[0], ...values[2] } :
134
- values.length === 1 ? values[0] :
135
- {});
136
- };
137
- // prettier-ignore
138
- const ModuleProperties = index_1.Runtime.Union([
139
- index_1.Runtime.Tuple([index_1.Runtime.Ref('ModuleType'), ModulePropertiesDelimiter, index_1.Runtime.Ref('ModuleProperties')]),
140
- index_1.Runtime.Tuple([index_1.Runtime.Ref('ModuleType')]),
141
- index_1.Runtime.Tuple([]),
142
- ], ModulePropertiesMapping);
143
- // ------------------------------------------------------------------
144
- // ModuleDeclaration
145
- // ------------------------------------------------------------------
146
- // prettier-ignore
147
- const ModuleIdentifier = index_1.Runtime.Union([
148
- index_1.Runtime.Tuple([index_1.Runtime.Ident()]),
149
- index_1.Runtime.Tuple([])
150
- ]);
151
- // prettier-ignore
152
- const ModuleDeclarationMapping = (_1, _2, _Ident, _3, Properties, _5) => {
153
- return Types.Module(Properties);
154
- };
155
- // prettier-ignore
156
- const ModuleDeclaration = index_1.Runtime.Tuple([
157
- index_1.Runtime.Ref('ExportModifier'), index_1.Runtime.Const('module'), ModuleIdentifier, index_1.Runtime.Const(LBrace), index_1.Runtime.Ref('ModuleProperties'), index_1.Runtime.Const(RBrace)
158
- ], values => ModuleDeclarationMapping(...values));
45
+ function GenericReferenceMapping(results, context) {
46
+ const target = Dereference(context, results[0]);
47
+ return t.Instantiate(target, results[2]);
48
+ }
49
+ const GenericReference = index_1.Runtime.Tuple([index_1.Runtime.Ident(), index_1.Runtime.Const(LAngle), index_1.Runtime.Ref('Elements'), index_1.Runtime.Const(RAngle)], (results, context) => GenericReferenceMapping(results, context));
159
50
  // ------------------------------------------------------------------
160
51
  // Reference
161
52
  // ------------------------------------------------------------------
53
+ function ReferenceMapping(result, context) {
54
+ const target = Dereference(context, result);
55
+ return target;
56
+ }
162
57
  // prettier-ignore
163
- const Reference = index_1.Runtime.Ident((value, context) => Deref(context, value));
58
+ const Reference = index_1.Runtime.Ident((result, context) => ReferenceMapping(result, context));
164
59
  // ------------------------------------------------------------------
165
60
  // Literal
166
61
  // ------------------------------------------------------------------
167
62
  // prettier-ignore
168
63
  const Literal = index_1.Runtime.Union([
169
- index_1.Runtime.Union([index_1.Runtime.Const('true'), index_1.Runtime.Const('false')], value => Types.Literal(value === 'true')),
170
- index_1.Runtime.Number(value => Types.Literal(parseFloat(value))),
171
- index_1.Runtime.String([SingleQuote, DoubleQuote, Tilde], value => Types.Literal(value))
64
+ index_1.Runtime.Union([index_1.Runtime.Const('true'), index_1.Runtime.Const('false')], value => t.Literal(value === 'true')),
65
+ index_1.Runtime.Number(value => t.Literal(parseFloat(value))),
66
+ index_1.Runtime.String([SingleQuote, DoubleQuote, Tilde], value => t.Literal(value))
172
67
  ]);
173
68
  // ------------------------------------------------------------------
174
69
  // Keyword
175
70
  // ------------------------------------------------------------------
176
71
  // prettier-ignore
177
72
  const Keyword = index_1.Runtime.Union([
178
- index_1.Runtime.Const('any', index_1.Runtime.As(Types.Any())),
179
- index_1.Runtime.Const('bigint', index_1.Runtime.As(Types.BigInt())),
180
- index_1.Runtime.Const('boolean', index_1.Runtime.As(Types.Boolean())),
181
- index_1.Runtime.Const('integer', index_1.Runtime.As(Types.Integer())),
182
- index_1.Runtime.Const('never', index_1.Runtime.As(Types.Never())),
183
- index_1.Runtime.Const('null', index_1.Runtime.As(Types.Null())),
184
- index_1.Runtime.Const('number', index_1.Runtime.As(Types.Number())),
185
- index_1.Runtime.Const('string', index_1.Runtime.As(Types.String())),
186
- index_1.Runtime.Const('symbol', index_1.Runtime.As(Types.Symbol())),
187
- index_1.Runtime.Const('undefined', index_1.Runtime.As(Types.Undefined())),
188
- index_1.Runtime.Const('unknown', index_1.Runtime.As(Types.Unknown())),
189
- index_1.Runtime.Const('void', index_1.Runtime.As(Types.Void())),
73
+ index_1.Runtime.Const('any', index_1.Runtime.As(t.Any())),
74
+ index_1.Runtime.Const('bigint', index_1.Runtime.As(t.BigInt())),
75
+ index_1.Runtime.Const('boolean', index_1.Runtime.As(t.Boolean())),
76
+ index_1.Runtime.Const('integer', index_1.Runtime.As(t.Integer())),
77
+ index_1.Runtime.Const('never', index_1.Runtime.As(t.Never())),
78
+ index_1.Runtime.Const('null', index_1.Runtime.As(t.Null())),
79
+ index_1.Runtime.Const('number', index_1.Runtime.As(t.Number())),
80
+ index_1.Runtime.Const('string', index_1.Runtime.As(t.String())),
81
+ index_1.Runtime.Const('symbol', index_1.Runtime.As(t.Symbol())),
82
+ index_1.Runtime.Const('undefined', index_1.Runtime.As(t.Undefined())),
83
+ index_1.Runtime.Const('unknown', index_1.Runtime.As(t.Unknown())),
84
+ index_1.Runtime.Const('void', index_1.Runtime.As(t.Void())),
190
85
  ]);
191
86
  // ------------------------------------------------------------------
192
87
  // KeyOf
@@ -252,6 +147,7 @@ const Base = index_1.Runtime.Union([
252
147
  index_1.Runtime.Ref('FunctionParameters'),
253
148
  index_1.Runtime.Ref('InstanceType'),
254
149
  index_1.Runtime.Ref('ReturnType'),
150
+ index_1.Runtime.Ref('Argument'),
255
151
  index_1.Runtime.Ref('Awaited'),
256
152
  index_1.Runtime.Ref('Array'),
257
153
  index_1.Runtime.Ref('Record'),
@@ -268,6 +164,7 @@ const Base = index_1.Runtime.Union([
268
164
  index_1.Runtime.Ref('Uncapitalize'),
269
165
  index_1.Runtime.Ref('Date'),
270
166
  index_1.Runtime.Ref('Uint8Array'),
167
+ index_1.Runtime.Ref('GenericReference'),
271
168
  index_1.Runtime.Ref('Reference')
272
169
  ])])
273
170
  ], BaseMapping);
@@ -277,22 +174,22 @@ const Base = index_1.Runtime.Union([
277
174
  // prettier-ignore
278
175
  const FactorExtends = (Type, Extends) => {
279
176
  return Extends.length === 3
280
- ? Types.Extends(Type, Extends[0], Extends[1], Extends[2])
177
+ ? t.Extends(Type, Extends[0], Extends[1], Extends[2])
281
178
  : Type;
282
179
  };
283
180
  // prettier-ignore
284
181
  const FactorIndexArray = (Type, IndexArray) => {
285
182
  const [Left, Right] = DestructureRight(IndexArray);
286
- return (!Types.ValueGuard.IsUndefined(Right) ? (
183
+ return (!t.ValueGuard.IsUndefined(Right) ? (
287
184
  // note: Indexed types require reimplementation to replace `[number]` indexers
288
- Right.length === 1 ? Types.Index(FactorIndexArray(Type, Left), Right[0]) :
289
- Right.length === 0 ? Types.Array(FactorIndexArray(Type, Left)) :
290
- Types.Never()) : Type);
185
+ Right.length === 1 ? t.Index(FactorIndexArray(Type, Left), Right[0]) :
186
+ Right.length === 0 ? t.Array(FactorIndexArray(Type, Left)) :
187
+ t.Never()) : Type);
291
188
  };
292
189
  // prettier-ignore
293
190
  const FactorMapping = (KeyOf, Type, IndexArray, Extends) => {
294
191
  return KeyOf
295
- ? FactorExtends(Types.KeyOf(FactorIndexArray(Type, IndexArray)), Extends)
192
+ ? FactorExtends(t.KeyOf(FactorIndexArray(Type, IndexArray)), Extends)
296
193
  : FactorExtends(FactorIndexArray(Type, IndexArray), Extends);
297
194
  };
298
195
  // prettier-ignore
@@ -311,14 +208,14 @@ function ExprBinaryMapping(Left, Rest) {
311
208
  const [Operator, Right, Next] = Rest;
312
209
  const Schema = ExprBinaryMapping(Right, Next);
313
210
  if (Operator === '&') {
314
- return Types.TypeGuard.IsIntersect(Schema)
315
- ? Types.Intersect([Left, ...Schema.allOf])
316
- : Types.Intersect([Left, Schema]);
211
+ return t.TypeGuard.IsIntersect(Schema)
212
+ ? t.Intersect([Left, ...Schema.allOf])
213
+ : t.Intersect([Left, Schema]);
317
214
  }
318
215
  if (Operator === '|') {
319
- return Types.TypeGuard.IsUnion(Schema)
320
- ? Types.Union([Left, ...Schema.anyOf])
321
- : Types.Union([Left, Schema]);
216
+ return t.TypeGuard.IsUnion(Schema)
217
+ ? t.Union([Left, ...Schema.anyOf])
218
+ : t.Union([Left, Schema]);
322
219
  }
323
220
  throw 1;
324
221
  })() : Left);
@@ -353,9 +250,9 @@ const Readonly = index_1.Runtime.Union([index_1.Runtime.Tuple([index_1.Runtime.C
353
250
  const Optional = index_1.Runtime.Union([index_1.Runtime.Tuple([index_1.Runtime.Const(Question)]), index_1.Runtime.Tuple([])], (value) => value.length > 0);
354
251
  // prettier-ignore
355
252
  const PropertyMapping = (IsReadonly, Key, IsOptional, _, Type) => ({
356
- [Key]: (IsReadonly && IsOptional ? Types.ReadonlyOptional(Type) :
357
- IsReadonly && !IsOptional ? Types.Readonly(Type) :
358
- !IsReadonly && IsOptional ? Types.Optional(Type) :
253
+ [Key]: (IsReadonly && IsOptional ? t.ReadonlyOptional(Type) :
254
+ IsReadonly && !IsOptional ? t.Readonly(Type) :
255
+ !IsReadonly && IsOptional ? t.Optional(Type) :
359
256
  Type)
360
257
  });
361
258
  // prettier-ignore
@@ -388,7 +285,7 @@ const Properties = index_1.Runtime.Union([
388
285
  // Object
389
286
  // ------------------------------------------------------------------
390
287
  // prettier-ignore
391
- const ObjectMapping = (_0, Properties, _2) => Types.Object(Properties);
288
+ const ObjectMapping = (_0, Properties, _2) => t.Object(Properties);
392
289
  // prettier-ignore
393
290
  const _Object = index_1.Runtime.Tuple([
394
291
  index_1.Runtime.Const(LBrace),
@@ -413,7 +310,7 @@ const Tuple = index_1.Runtime.Tuple([
413
310
  index_1.Runtime.Const(LBracket),
414
311
  index_1.Runtime.Ref('Elements'),
415
312
  index_1.Runtime.Const(RBracket)
416
- ], value => Types.Tuple(value[1]));
313
+ ], value => t.Tuple(value[1]));
417
314
  // ------------------------------------------------------------------
418
315
  // Parameters
419
316
  // ------------------------------------------------------------------
@@ -442,7 +339,7 @@ const Constructor = index_1.Runtime.Tuple([
442
339
  index_1.Runtime.Const(RParen),
443
340
  index_1.Runtime.Const('=>'),
444
341
  index_1.Runtime.Ref('Type')
445
- ], value => Types.Constructor(value[2], value[5]));
342
+ ], value => t.Constructor(value[2], value[5]));
446
343
  // ------------------------------------------------------------------
447
344
  // Function
448
345
  // ------------------------------------------------------------------
@@ -453,13 +350,13 @@ const Function = index_1.Runtime.Tuple([
453
350
  index_1.Runtime.Const(RParen),
454
351
  index_1.Runtime.Const('=>'),
455
352
  index_1.Runtime.Ref('Type')
456
- ], value => Types.Function(value[1], value[4]));
353
+ ], value => t.Function(value[1], value[4]));
457
354
  // ------------------------------------------------------------------
458
355
  // Mapped (requires deferred types)
459
356
  // ------------------------------------------------------------------
460
357
  // prettier-ignore
461
358
  const MappedMapping = (values) => {
462
- return Types.Literal('Mapped types not supported');
359
+ return t.Literal('Mapped types not supported');
463
360
  };
464
361
  // prettier-ignore
465
362
  const Mapped = index_1.Runtime.Tuple([
@@ -482,7 +379,7 @@ const AsyncIterator = index_1.Runtime.Tuple([
482
379
  index_1.Runtime.Const(LAngle),
483
380
  index_1.Runtime.Ref('Type'),
484
381
  index_1.Runtime.Const(RAngle),
485
- ], value => Types.AsyncIterator(value[2]));
382
+ ], value => t.AsyncIterator(value[2]));
486
383
  // ------------------------------------------------------------------
487
384
  // Iterator
488
385
  // ------------------------------------------------------------------
@@ -492,7 +389,7 @@ const Iterator = index_1.Runtime.Tuple([
492
389
  index_1.Runtime.Const(LAngle),
493
390
  index_1.Runtime.Ref('Type'),
494
391
  index_1.Runtime.Const(RAngle),
495
- ], value => Types.Iterator(value[2]));
392
+ ], value => t.Iterator(value[2]));
496
393
  // ------------------------------------------------------------------
497
394
  // ConstructorParameters
498
395
  // ------------------------------------------------------------------
@@ -502,7 +399,7 @@ const ConstructorParameters = index_1.Runtime.Tuple([
502
399
  index_1.Runtime.Const(LAngle),
503
400
  index_1.Runtime.Ref('Type'),
504
401
  index_1.Runtime.Const(RAngle),
505
- ], value => Types.ConstructorParameters(value[2]));
402
+ ], value => t.ConstructorParameters(value[2]));
506
403
  // ------------------------------------------------------------------
507
404
  // Parameters
508
405
  // ------------------------------------------------------------------
@@ -512,7 +409,7 @@ const FunctionParameters = index_1.Runtime.Tuple([
512
409
  index_1.Runtime.Const(LAngle),
513
410
  index_1.Runtime.Ref('Type'),
514
411
  index_1.Runtime.Const(RAngle),
515
- ], value => Types.Parameters(value[2]));
412
+ ], value => t.Parameters(value[2]));
516
413
  // ------------------------------------------------------------------
517
414
  // InstanceType
518
415
  // ------------------------------------------------------------------
@@ -522,7 +419,7 @@ const InstanceType = index_1.Runtime.Tuple([
522
419
  index_1.Runtime.Const(LAngle),
523
420
  index_1.Runtime.Ref('Type'),
524
421
  index_1.Runtime.Const(RAngle),
525
- ], value => Types.InstanceType(value[2]));
422
+ ], value => t.InstanceType(value[2]));
526
423
  // ------------------------------------------------------------------
527
424
  // ReturnType
528
425
  // ------------------------------------------------------------------
@@ -532,7 +429,21 @@ const ReturnType = index_1.Runtime.Tuple([
532
429
  index_1.Runtime.Const(LAngle),
533
430
  index_1.Runtime.Ref('Type'),
534
431
  index_1.Runtime.Const(RAngle),
535
- ], value => Types.ReturnType(value[2]));
432
+ ], value => t.ReturnType(value[2]));
433
+ // ------------------------------------------------------------------
434
+ // Argument
435
+ // ------------------------------------------------------------------
436
+ // prettier-ignore
437
+ const Argument = index_1.Runtime.Tuple([
438
+ index_1.Runtime.Const('Argument'),
439
+ index_1.Runtime.Const(LAngle),
440
+ index_1.Runtime.Ref('Type'),
441
+ index_1.Runtime.Const(RAngle),
442
+ ], results => {
443
+ return t.KindGuard.IsLiteralNumber(results[2])
444
+ ? t.Argument(Math.trunc(results[2].const))
445
+ : t.Never();
446
+ });
536
447
  // ------------------------------------------------------------------
537
448
  // Awaited
538
449
  // ------------------------------------------------------------------
@@ -542,7 +453,7 @@ const Awaited = index_1.Runtime.Tuple([
542
453
  index_1.Runtime.Const(LAngle),
543
454
  index_1.Runtime.Ref('Type'),
544
455
  index_1.Runtime.Const(RAngle),
545
- ], value => Types.Awaited(value[2]));
456
+ ], value => t.Awaited(value[2]));
546
457
  // ------------------------------------------------------------------
547
458
  // Array
548
459
  // ------------------------------------------------------------------
@@ -552,7 +463,7 @@ const Array = index_1.Runtime.Tuple([
552
463
  index_1.Runtime.Const(LAngle),
553
464
  index_1.Runtime.Ref('Type'),
554
465
  index_1.Runtime.Const(RAngle),
555
- ], value => Types.Array(value[2]));
466
+ ], value => t.Array(value[2]));
556
467
  // ------------------------------------------------------------------
557
468
  // Record
558
469
  // ------------------------------------------------------------------
@@ -564,7 +475,7 @@ const Record = index_1.Runtime.Tuple([
564
475
  index_1.Runtime.Const(Comma),
565
476
  index_1.Runtime.Ref('Type'),
566
477
  index_1.Runtime.Const(RAngle),
567
- ], value => Types.Record(value[2], value[4]));
478
+ ], value => t.Record(value[2], value[4]));
568
479
  // ------------------------------------------------------------------
569
480
  // Promise
570
481
  // ------------------------------------------------------------------
@@ -574,7 +485,7 @@ const Promise = index_1.Runtime.Tuple([
574
485
  index_1.Runtime.Const(LAngle),
575
486
  index_1.Runtime.Ref('Type'),
576
487
  index_1.Runtime.Const(RAngle),
577
- ], value => Types.Promise(value[2]));
488
+ ], value => t.Promise(value[2]));
578
489
  // ------------------------------------------------------------------
579
490
  // Partial
580
491
  // ------------------------------------------------------------------
@@ -584,7 +495,7 @@ const Partial = index_1.Runtime.Tuple([
584
495
  index_1.Runtime.Const(LAngle),
585
496
  index_1.Runtime.Ref('Type'),
586
497
  index_1.Runtime.Const(RAngle),
587
- ], value => Types.Partial(value[2]));
498
+ ], value => t.Partial(value[2]));
588
499
  // ------------------------------------------------------------------
589
500
  // Required
590
501
  // ------------------------------------------------------------------
@@ -594,7 +505,7 @@ const Required = index_1.Runtime.Tuple([
594
505
  index_1.Runtime.Const(LAngle),
595
506
  index_1.Runtime.Ref('Type'),
596
507
  index_1.Runtime.Const(RAngle),
597
- ], value => Types.Required(value[2]));
508
+ ], value => t.Required(value[2]));
598
509
  // ------------------------------------------------------------------
599
510
  // Pick
600
511
  // ------------------------------------------------------------------
@@ -606,7 +517,7 @@ const Pick = index_1.Runtime.Tuple([
606
517
  index_1.Runtime.Const(Comma),
607
518
  index_1.Runtime.Ref('Type'),
608
519
  index_1.Runtime.Const(RAngle),
609
- ], value => Types.Pick(value[2], value[4]));
520
+ ], value => t.Pick(value[2], value[4]));
610
521
  // ------------------------------------------------------------------
611
522
  // Omit
612
523
  // ------------------------------------------------------------------
@@ -618,7 +529,7 @@ const Omit = index_1.Runtime.Tuple([
618
529
  index_1.Runtime.Const(Comma),
619
530
  index_1.Runtime.Ref('Type'),
620
531
  index_1.Runtime.Const(RAngle),
621
- ], value => Types.Omit(value[2], value[4]));
532
+ ], value => t.Omit(value[2], value[4]));
622
533
  // ------------------------------------------------------------------
623
534
  // Exclude
624
535
  // ------------------------------------------------------------------
@@ -630,7 +541,7 @@ const Exclude = index_1.Runtime.Tuple([
630
541
  index_1.Runtime.Const(Comma),
631
542
  index_1.Runtime.Ref('Type'),
632
543
  index_1.Runtime.Const(RAngle),
633
- ], value => Types.Exclude(value[2], value[4]));
544
+ ], value => t.Exclude(value[2], value[4]));
634
545
  // ------------------------------------------------------------------
635
546
  // Extract
636
547
  // ------------------------------------------------------------------
@@ -642,7 +553,7 @@ const Extract = index_1.Runtime.Tuple([
642
553
  index_1.Runtime.Const(Comma),
643
554
  index_1.Runtime.Ref('Type'),
644
555
  index_1.Runtime.Const(RAngle),
645
- ], value => Types.Extract(value[2], value[4]));
556
+ ], value => t.Extract(value[2], value[4]));
646
557
  // ------------------------------------------------------------------
647
558
  // Uppercase
648
559
  // ------------------------------------------------------------------
@@ -652,7 +563,7 @@ const Uppercase = index_1.Runtime.Tuple([
652
563
  index_1.Runtime.Const(LAngle),
653
564
  index_1.Runtime.Ref('Type'),
654
565
  index_1.Runtime.Const(RAngle),
655
- ], value => Types.Uppercase(value[2]));
566
+ ], value => t.Uppercase(value[2]));
656
567
  // ------------------------------------------------------------------
657
568
  // Lowercase
658
569
  // ------------------------------------------------------------------
@@ -662,7 +573,7 @@ const Lowercase = index_1.Runtime.Tuple([
662
573
  index_1.Runtime.Const(LAngle),
663
574
  index_1.Runtime.Ref('Type'),
664
575
  index_1.Runtime.Const(RAngle),
665
- ], value => Types.Lowercase(value[2]));
576
+ ], value => t.Lowercase(value[2]));
666
577
  // ------------------------------------------------------------------
667
578
  // Capitalize
668
579
  // ------------------------------------------------------------------
@@ -672,7 +583,7 @@ const Capitalize = index_1.Runtime.Tuple([
672
583
  index_1.Runtime.Const(LAngle),
673
584
  index_1.Runtime.Ref('Type'),
674
585
  index_1.Runtime.Const(RAngle),
675
- ], value => Types.Capitalize(value[2]));
586
+ ], value => t.Capitalize(value[2]));
676
587
  // ------------------------------------------------------------------
677
588
  // Uncapitalize
678
589
  // ------------------------------------------------------------------
@@ -682,41 +593,20 @@ const Uncapitalize = index_1.Runtime.Tuple([
682
593
  index_1.Runtime.Const(LAngle),
683
594
  index_1.Runtime.Ref('Type'),
684
595
  index_1.Runtime.Const(RAngle),
685
- ], value => Types.Uncapitalize(value[2]));
596
+ ], value => t.Uncapitalize(value[2]));
686
597
  // ------------------------------------------------------------------
687
598
  // Date
688
599
  // ------------------------------------------------------------------
689
- const Date = index_1.Runtime.Const('Date', index_1.Runtime.As(Types.Date()));
600
+ const Date = index_1.Runtime.Const('Date', index_1.Runtime.As(t.Date()));
690
601
  // ------------------------------------------------------------------
691
602
  // Uint8Array
692
603
  // ------------------------------------------------------------------
693
- const Uint8Array = index_1.Runtime.Const('Uint8Array', index_1.Runtime.As(Types.Uint8Array()));
694
- // ------------------------------------------------------------------
695
- // Main
696
- // ------------------------------------------------------------------
697
- // prettier-ignore
698
- const Main = index_1.Runtime.Union([
699
- ModuleDeclaration,
700
- TypeAliasDeclaration,
701
- InterfaceDeclaration,
702
- Type
703
- ]);
604
+ const Uint8Array = index_1.Runtime.Const('Uint8Array', index_1.Runtime.As(t.Uint8Array()));
704
605
  // ------------------------------------------------------------------
705
606
  // Module
706
607
  // ------------------------------------------------------------------
707
608
  // prettier-ignore
708
609
  exports.Module = new index_1.Runtime.Module({
709
- // ----------------------------------------------------------------
710
- // Modules, Interfaces and Type Aliases
711
- // ----------------------------------------------------------------
712
- ExportModifier,
713
- HeritageList,
714
- Heritage,
715
- InterfaceDeclaration,
716
- TypeAliasDeclaration,
717
- ModuleType,
718
- ModuleProperties,
719
- ModuleDeclaration,
720
610
  // ----------------------------------------------------------------
721
611
  // Type Expressions
722
612
  // ----------------------------------------------------------------
@@ -748,6 +638,7 @@ exports.Module = new index_1.Runtime.Module({
748
638
  Mapped,
749
639
  AsyncIterator,
750
640
  Iterator,
641
+ Argument,
751
642
  Awaited,
752
643
  Array,
753
644
  Record,
@@ -768,9 +659,6 @@ exports.Module = new index_1.Runtime.Module({
768
659
  Uncapitalize,
769
660
  Date,
770
661
  Uint8Array,
662
+ GenericReference,
771
663
  Reference,
772
- // ----------------------------------------------------------------
773
- // Main
774
- // ----------------------------------------------------------------
775
- Main
776
664
  });