arktype 1.0.14-alpha → 1.0.16-alpha

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 (247) hide show
  1. package/README.md +68 -11
  2. package/dist/main.js +29 -0
  3. package/dist/nodes/branch.js +135 -0
  4. package/dist/nodes/compose.js +99 -0
  5. package/dist/{cjs/nodes → nodes}/discriminate.js +100 -92
  6. package/dist/nodes/node.js +134 -0
  7. package/dist/nodes/predicate.js +88 -0
  8. package/dist/nodes/rules/class.js +23 -0
  9. package/dist/nodes/rules/collapsibleSet.js +34 -0
  10. package/dist/nodes/rules/divisor.js +19 -0
  11. package/dist/nodes/rules/props.js +130 -0
  12. package/dist/nodes/rules/range.js +108 -0
  13. package/dist/nodes/rules/regex.js +17 -0
  14. package/dist/nodes/rules/rules.js +102 -0
  15. package/dist/parse/ast/ast.js +2 -0
  16. package/dist/parse/ast/bound.js +7 -0
  17. package/dist/parse/ast/config.js +14 -0
  18. package/dist/parse/ast/distributableFunction.js +40 -0
  19. package/dist/parse/ast/divisor.js +5 -0
  20. package/dist/parse/ast/intersection.js +21 -0
  21. package/dist/parse/ast/keyof.js +107 -0
  22. package/dist/parse/ast/morph.js +50 -0
  23. package/dist/parse/ast/narrow.js +17 -0
  24. package/dist/{types/parse → parse}/ast/node.d.ts +3 -1
  25. package/dist/parse/ast/node.js +2 -0
  26. package/dist/parse/ast/tuple.js +72 -0
  27. package/dist/parse/ast/union.js +5 -0
  28. package/dist/parse/ast/utils.js +2 -0
  29. package/dist/parse/definition.js +47 -0
  30. package/dist/parse/record.js +31 -0
  31. package/dist/parse/string/reduce/dynamic.js +159 -0
  32. package/dist/parse/string/reduce/shared.js +13 -0
  33. package/dist/parse/string/reduce/static.js +2 -0
  34. package/dist/parse/string/shift/operand/enclosed.js +37 -0
  35. package/dist/parse/string/shift/operand/operand.js +15 -0
  36. package/dist/parse/string/shift/operand/unenclosed.js +45 -0
  37. package/dist/parse/string/shift/operator/bounds.js +83 -0
  38. package/dist/parse/string/shift/operator/divisor.js +23 -0
  39. package/dist/parse/string/shift/operator/operator.js +34 -0
  40. package/dist/parse/string/shift/scanner.js +97 -0
  41. package/dist/parse/string/string.js +35 -0
  42. package/dist/scopes/ark.js +27 -0
  43. package/dist/scopes/cache.js +28 -0
  44. package/dist/{mjs/scopes → scopes}/expressions.js +20 -9
  45. package/dist/scopes/jsObjects.js +20 -0
  46. package/dist/scopes/scope.js +184 -0
  47. package/dist/scopes/tsKeywords.js +49 -0
  48. package/dist/scopes/type.js +40 -0
  49. package/dist/{mjs/scopes → scopes}/validation/creditCard.js +15 -11
  50. package/dist/{mjs/scopes → scopes}/validation/date.js +21 -16
  51. package/dist/scopes/validation/validation.js +74 -0
  52. package/dist/traverse/problems.js +234 -0
  53. package/dist/traverse/traverse.js +330 -0
  54. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  55. package/dist/{mjs/utils → utils}/chainableNoOpProxy.js +6 -2
  56. package/dist/utils/data.js +39 -0
  57. package/dist/utils/domains.js +27 -0
  58. package/dist/utils/errors.js +17 -0
  59. package/dist/utils/freeze.js +16 -0
  60. package/dist/{types/utils → utils}/generics.d.ts +2 -2
  61. package/dist/utils/generics.js +53 -0
  62. package/dist/utils/numericLiterals.js +88 -0
  63. package/dist/utils/objectKinds.js +69 -0
  64. package/dist/{mjs/utils → utils}/paths.js +8 -3
  65. package/dist/utils/serialize.js +71 -0
  66. package/dist/utils/unionToTuple.js +2 -0
  67. package/package.json +26 -39
  68. package/dist/cjs/main.js +0 -38
  69. package/dist/cjs/nodes/branch.js +0 -140
  70. package/dist/cjs/nodes/compose.js +0 -157
  71. package/dist/cjs/nodes/node.js +0 -139
  72. package/dist/cjs/nodes/predicate.js +0 -86
  73. package/dist/cjs/nodes/rules/class.js +0 -25
  74. package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
  75. package/dist/cjs/nodes/rules/divisor.js +0 -29
  76. package/dist/cjs/nodes/rules/props.js +0 -160
  77. package/dist/cjs/nodes/rules/range.js +0 -105
  78. package/dist/cjs/nodes/rules/regex.js +0 -26
  79. package/dist/cjs/nodes/rules/rules.js +0 -123
  80. package/dist/cjs/parse/ast/ast.js +0 -4
  81. package/dist/cjs/parse/ast/bound.js +0 -16
  82. package/dist/cjs/parse/ast/config.js +0 -13
  83. package/dist/cjs/parse/ast/distributableFunction.js +0 -48
  84. package/dist/cjs/parse/ast/divisor.js +0 -9
  85. package/dist/cjs/parse/ast/intersection.js +0 -30
  86. package/dist/cjs/parse/ast/keyof.js +0 -111
  87. package/dist/cjs/parse/ast/morph.js +0 -58
  88. package/dist/cjs/parse/ast/narrow.js +0 -22
  89. package/dist/cjs/parse/ast/node.js +0 -4
  90. package/dist/cjs/parse/ast/tuple.js +0 -94
  91. package/dist/cjs/parse/ast/union.js +0 -9
  92. package/dist/cjs/parse/ast/utils.js +0 -4
  93. package/dist/cjs/parse/definition.js +0 -61
  94. package/dist/cjs/parse/record.js +0 -37
  95. package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
  96. package/dist/cjs/parse/string/reduce/shared.js +0 -23
  97. package/dist/cjs/parse/string/reduce/static.js +0 -4
  98. package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
  99. package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
  100. package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
  101. package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
  102. package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
  103. package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
  104. package/dist/cjs/parse/string/shift/scanner.js +0 -114
  105. package/dist/cjs/parse/string/string.js +0 -43
  106. package/dist/cjs/scopes/ark.js +0 -45
  107. package/dist/cjs/scopes/cache.js +0 -52
  108. package/dist/cjs/scopes/expressions.js +0 -29
  109. package/dist/cjs/scopes/jsObjects.js +0 -93
  110. package/dist/cjs/scopes/scope.js +0 -323
  111. package/dist/cjs/scopes/tsKeywords.js +0 -113
  112. package/dist/cjs/scopes/type.js +0 -50
  113. package/dist/cjs/scopes/validation/creditCard.js +0 -47
  114. package/dist/cjs/scopes/validation/date.js +0 -62
  115. package/dist/cjs/scopes/validation/validation.js +0 -104
  116. package/dist/cjs/traverse/problems.js +0 -281
  117. package/dist/cjs/traverse/traverse.js +0 -390
  118. package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
  119. package/dist/cjs/utils/data.js +0 -53
  120. package/dist/cjs/utils/domains.js +0 -30
  121. package/dist/cjs/utils/errors.js +0 -26
  122. package/dist/cjs/utils/freeze.js +0 -15
  123. package/dist/cjs/utils/generics.js +0 -63
  124. package/dist/cjs/utils/numericLiterals.js +0 -75
  125. package/dist/cjs/utils/objectKinds.js +0 -69
  126. package/dist/cjs/utils/paths.js +0 -32
  127. package/dist/cjs/utils/serialize.js +0 -74
  128. package/dist/cjs/utils/unionToTuple.js +0 -4
  129. package/dist/mjs/main.js +0 -8
  130. package/dist/mjs/nodes/branch.js +0 -123
  131. package/dist/mjs/nodes/compose.js +0 -135
  132. package/dist/mjs/nodes/discriminate.js +0 -247
  133. package/dist/mjs/nodes/node.js +0 -117
  134. package/dist/mjs/nodes/predicate.js +0 -69
  135. package/dist/mjs/nodes/rules/class.js +0 -11
  136. package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
  137. package/dist/mjs/nodes/rules/divisor.js +0 -15
  138. package/dist/mjs/nodes/rules/props.js +0 -142
  139. package/dist/mjs/nodes/rules/range.js +0 -86
  140. package/dist/mjs/nodes/rules/regex.js +0 -11
  141. package/dist/mjs/nodes/rules/rules.js +0 -106
  142. package/dist/mjs/package.json +0 -3
  143. package/dist/mjs/parse/ast/ast.js +0 -1
  144. package/dist/mjs/parse/ast/bound.js +0 -2
  145. package/dist/mjs/parse/ast/config.js +0 -9
  146. package/dist/mjs/parse/ast/distributableFunction.js +0 -34
  147. package/dist/mjs/parse/ast/divisor.js +0 -1
  148. package/dist/mjs/parse/ast/intersection.js +0 -16
  149. package/dist/mjs/parse/ast/keyof.js +0 -103
  150. package/dist/mjs/parse/ast/morph.js +0 -44
  151. package/dist/mjs/parse/ast/narrow.js +0 -14
  152. package/dist/mjs/parse/ast/node.js +0 -1
  153. package/dist/mjs/parse/ast/tuple.js +0 -80
  154. package/dist/mjs/parse/ast/union.js +0 -1
  155. package/dist/mjs/parse/ast/utils.js +0 -1
  156. package/dist/mjs/parse/definition.js +0 -46
  157. package/dist/mjs/parse/record.js +0 -29
  158. package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
  159. package/dist/mjs/parse/string/reduce/shared.js +0 -6
  160. package/dist/mjs/parse/string/reduce/static.js +0 -1
  161. package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
  162. package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
  163. package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
  164. package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
  165. package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
  166. package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
  167. package/dist/mjs/parse/string/shift/scanner.js +0 -106
  168. package/dist/mjs/parse/string/string.js +0 -28
  169. package/dist/mjs/scopes/ark.js +0 -28
  170. package/dist/mjs/scopes/cache.js +0 -38
  171. package/dist/mjs/scopes/jsObjects.js +0 -82
  172. package/dist/mjs/scopes/scope.js +0 -303
  173. package/dist/mjs/scopes/tsKeywords.js +0 -116
  174. package/dist/mjs/scopes/type.js +0 -35
  175. package/dist/mjs/scopes/validation/validation.js +0 -108
  176. package/dist/mjs/traverse/problems.js +0 -260
  177. package/dist/mjs/traverse/traverse.js +0 -373
  178. package/dist/mjs/utils/data.js +0 -38
  179. package/dist/mjs/utils/domains.js +0 -15
  180. package/dist/mjs/utils/errors.js +0 -10
  181. package/dist/mjs/utils/freeze.js +0 -7
  182. package/dist/mjs/utils/generics.js +0 -38
  183. package/dist/mjs/utils/numericLiterals.js +0 -72
  184. package/dist/mjs/utils/objectKinds.js +0 -55
  185. package/dist/mjs/utils/serialize.js +0 -58
  186. package/dist/mjs/utils/unionToTuple.js +0 -1
  187. /package/dist/{types/main.d.ts → main.d.ts} +0 -0
  188. /package/dist/{types/nodes → nodes}/branch.d.ts +0 -0
  189. /package/dist/{types/nodes → nodes}/compose.d.ts +0 -0
  190. /package/dist/{types/nodes → nodes}/discriminate.d.ts +0 -0
  191. /package/dist/{types/nodes → nodes}/node.d.ts +0 -0
  192. /package/dist/{types/nodes → nodes}/predicate.d.ts +0 -0
  193. /package/dist/{types/nodes → nodes}/rules/class.d.ts +0 -0
  194. /package/dist/{types/nodes → nodes}/rules/collapsibleSet.d.ts +0 -0
  195. /package/dist/{types/nodes → nodes}/rules/divisor.d.ts +0 -0
  196. /package/dist/{types/nodes → nodes}/rules/props.d.ts +0 -0
  197. /package/dist/{types/nodes → nodes}/rules/range.d.ts +0 -0
  198. /package/dist/{types/nodes → nodes}/rules/regex.d.ts +0 -0
  199. /package/dist/{types/nodes → nodes}/rules/rules.d.ts +0 -0
  200. /package/dist/{cjs/package.json → package.json} +0 -0
  201. /package/dist/{types/parse → parse}/ast/ast.d.ts +0 -0
  202. /package/dist/{types/parse → parse}/ast/bound.d.ts +0 -0
  203. /package/dist/{types/parse → parse}/ast/config.d.ts +0 -0
  204. /package/dist/{types/parse → parse}/ast/distributableFunction.d.ts +0 -0
  205. /package/dist/{types/parse → parse}/ast/divisor.d.ts +0 -0
  206. /package/dist/{types/parse → parse}/ast/intersection.d.ts +0 -0
  207. /package/dist/{types/parse → parse}/ast/keyof.d.ts +0 -0
  208. /package/dist/{types/parse → parse}/ast/morph.d.ts +0 -0
  209. /package/dist/{types/parse → parse}/ast/narrow.d.ts +0 -0
  210. /package/dist/{types/parse → parse}/ast/tuple.d.ts +0 -0
  211. /package/dist/{types/parse → parse}/ast/union.d.ts +0 -0
  212. /package/dist/{types/parse → parse}/ast/utils.d.ts +0 -0
  213. /package/dist/{types/parse → parse}/definition.d.ts +0 -0
  214. /package/dist/{types/parse → parse}/record.d.ts +0 -0
  215. /package/dist/{types/parse → parse}/string/reduce/dynamic.d.ts +0 -0
  216. /package/dist/{types/parse → parse}/string/reduce/shared.d.ts +0 -0
  217. /package/dist/{types/parse → parse}/string/reduce/static.d.ts +0 -0
  218. /package/dist/{types/parse → parse}/string/shift/operand/enclosed.d.ts +0 -0
  219. /package/dist/{types/parse → parse}/string/shift/operand/operand.d.ts +0 -0
  220. /package/dist/{types/parse → parse}/string/shift/operand/unenclosed.d.ts +0 -0
  221. /package/dist/{types/parse → parse}/string/shift/operator/bounds.d.ts +0 -0
  222. /package/dist/{types/parse → parse}/string/shift/operator/divisor.d.ts +0 -0
  223. /package/dist/{types/parse → parse}/string/shift/operator/operator.d.ts +0 -0
  224. /package/dist/{types/parse → parse}/string/shift/scanner.d.ts +0 -0
  225. /package/dist/{types/parse → parse}/string/string.d.ts +0 -0
  226. /package/dist/{types/scopes → scopes}/ark.d.ts +0 -0
  227. /package/dist/{types/scopes → scopes}/cache.d.ts +0 -0
  228. /package/dist/{types/scopes → scopes}/expressions.d.ts +0 -0
  229. /package/dist/{types/scopes → scopes}/jsObjects.d.ts +0 -0
  230. /package/dist/{types/scopes → scopes}/scope.d.ts +0 -0
  231. /package/dist/{types/scopes → scopes}/tsKeywords.d.ts +0 -0
  232. /package/dist/{types/scopes → scopes}/type.d.ts +0 -0
  233. /package/dist/{types/scopes → scopes}/validation/creditCard.d.ts +0 -0
  234. /package/dist/{types/scopes → scopes}/validation/date.d.ts +0 -0
  235. /package/dist/{types/scopes → scopes}/validation/validation.d.ts +0 -0
  236. /package/dist/{types/traverse → traverse}/problems.d.ts +0 -0
  237. /package/dist/{types/traverse → traverse}/traverse.d.ts +0 -0
  238. /package/dist/{types/utils → utils}/chainableNoOpProxy.d.ts +0 -0
  239. /package/dist/{types/utils → utils}/data.d.ts +0 -0
  240. /package/dist/{types/utils → utils}/domains.d.ts +0 -0
  241. /package/dist/{types/utils → utils}/errors.d.ts +0 -0
  242. /package/dist/{types/utils → utils}/freeze.d.ts +0 -0
  243. /package/dist/{types/utils → utils}/numericLiterals.d.ts +0 -0
  244. /package/dist/{types/utils → utils}/objectKinds.d.ts +0 -0
  245. /package/dist/{types/utils → utils}/paths.d.ts +0 -0
  246. /package/dist/{types/utils → utils}/serialize.d.ts +0 -0
  247. /package/dist/{types/utils → utils}/unionToTuple.d.ts +0 -0
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenProps = exports.propsIntersection = exports.propToNode = exports.mappedKeys = exports.isPrerequisite = exports.isOptional = void 0;
4
+ const compose_js_1 = require("../compose.js");
5
+ const node_js_1 = require("../node.js");
6
+ const isOptional = (prop) => prop[0] === "?";
7
+ exports.isOptional = isOptional;
8
+ const isPrerequisite = (prop) => prop[0] === "!";
9
+ exports.isPrerequisite = isPrerequisite;
10
+ exports.mappedKeys = {
11
+ index: "[index]"
12
+ };
13
+ const propToNode = (prop) => (0, exports.isOptional)(prop) || (0, exports.isPrerequisite)(prop) ? prop[1] : prop;
14
+ exports.propToNode = propToNode;
15
+ const getTupleLengthIfPresent = (result) => {
16
+ if (typeof result.length === "object" &&
17
+ (0, exports.isPrerequisite)(result.length) &&
18
+ typeof result.length[1] !== "string" &&
19
+ (0, node_js_1.isLiteralNode)(result.length[1], "number")) {
20
+ return result.length[1].number.value;
21
+ }
22
+ };
23
+ exports.propsIntersection = (0, compose_js_1.composeIntersection)((l, r, state) => {
24
+ const result = propKeysIntersection(l, r, state);
25
+ if (typeof result === "symbol") {
26
+ return result;
27
+ }
28
+ const lengthValue = getTupleLengthIfPresent(result);
29
+ if (lengthValue === undefined || !(exports.mappedKeys.index in result)) {
30
+ return result;
31
+ }
32
+ // if we are at this point, we have an array with an exact length (i.e.
33
+ // a tuple) and an index signature. Intersection each tuple item with
34
+ // the index signature node and remove the index signature via a new
35
+ // updated result, copied from result to avoid mutating existing references.
36
+ const { [exports.mappedKeys.index]: indexProp, ...updatedResult } = result;
37
+ const indexNode = (0, exports.propToNode)(indexProp);
38
+ for (let i = 0; i < lengthValue; i++) {
39
+ if (!updatedResult[i]) {
40
+ updatedResult[i] = indexNode;
41
+ continue;
42
+ }
43
+ const existingNodeAtIndex = (0, exports.propToNode)(updatedResult[i]);
44
+ state.path.push(`${i}`);
45
+ const updatedResultAtIndex = (0, node_js_1.nodeIntersection)(existingNodeAtIndex, indexNode, state);
46
+ state.path.pop();
47
+ if ((0, compose_js_1.isDisjoint)(updatedResultAtIndex)) {
48
+ return updatedResultAtIndex;
49
+ }
50
+ else if (!(0, compose_js_1.isEquality)(updatedResultAtIndex) &&
51
+ updatedResultAtIndex !== existingNodeAtIndex) {
52
+ updatedResult[i] = updatedResultAtIndex;
53
+ }
54
+ }
55
+ return updatedResult;
56
+ });
57
+ const propKeysIntersection = (0, compose_js_1.composeKeyedIntersection)((propKey, l, r, context) => {
58
+ if (l === undefined) {
59
+ return r === undefined ? (0, compose_js_1.equality)() : r;
60
+ }
61
+ if (r === undefined) {
62
+ return l;
63
+ }
64
+ context.path.push(propKey);
65
+ const result = (0, node_js_1.nodeIntersection)((0, exports.propToNode)(l), (0, exports.propToNode)(r), context);
66
+ context.path.pop();
67
+ const resultIsOptional = (0, exports.isOptional)(l) && (0, exports.isOptional)(r);
68
+ if ((0, compose_js_1.isDisjoint)(result) && resultIsOptional) {
69
+ // If an optional key has an empty intersection, the type can
70
+ // still be satisfied as long as the key is not included. Set
71
+ // the node to never rather than invalidating the type.
72
+ return {};
73
+ }
74
+ return result;
75
+ }, { onEmpty: "bubble" });
76
+ const flattenProps = (entries, props, ctx) => {
77
+ const keyConfig = ctx.type.config?.keys ?? ctx.type.scope.config.keys;
78
+ return keyConfig === "loose"
79
+ ? flattenLooseProps(entries, props, ctx)
80
+ : flattenPropsRecord(keyConfig, entries, props, ctx);
81
+ };
82
+ exports.flattenProps = flattenProps;
83
+ const flattenLooseProps = (entries, props, ctx) => {
84
+ // if we don't care about extraneous keys, flatten props so we can iterate over the definitions directly
85
+ for (const k in props) {
86
+ const prop = props[k];
87
+ ctx.path.push(k);
88
+ if (k === exports.mappedKeys.index) {
89
+ entries.push(["indexProp", (0, node_js_1.flattenNode)((0, exports.propToNode)(prop), ctx)]);
90
+ }
91
+ else if ((0, exports.isOptional)(prop)) {
92
+ entries.push(["optionalProp", [k, (0, node_js_1.flattenNode)(prop[1], ctx)]]);
93
+ }
94
+ else if ((0, exports.isPrerequisite)(prop)) {
95
+ entries.push(["prerequisiteProp", [k, (0, node_js_1.flattenNode)(prop[1], ctx)]]);
96
+ }
97
+ else {
98
+ entries.push(["requiredProp", [k, (0, node_js_1.flattenNode)(prop, ctx)]]);
99
+ }
100
+ ctx.path.pop();
101
+ }
102
+ };
103
+ const flattenPropsRecord = (kind, entries, props, ctx) => {
104
+ const result = {
105
+ required: {},
106
+ optional: {}
107
+ };
108
+ // if we need to keep track of extraneous keys, either to add problems or
109
+ // remove them, store the props as a Record to optimize for presence
110
+ // checking as we iterate over the data
111
+ for (const k in props) {
112
+ const prop = props[k];
113
+ ctx.path.push(k);
114
+ if (k === exports.mappedKeys.index) {
115
+ result.index = (0, node_js_1.flattenNode)((0, exports.propToNode)(prop), ctx);
116
+ }
117
+ else if ((0, exports.isOptional)(prop)) {
118
+ result.optional[k] = (0, node_js_1.flattenNode)(prop[1], ctx);
119
+ }
120
+ else if ((0, exports.isPrerequisite)(prop)) {
121
+ // we still have to push prerequisite props as normal entries so they can be checked first
122
+ entries.push(["prerequisiteProp", [k, (0, node_js_1.flattenNode)(prop[1], ctx)]]);
123
+ }
124
+ else {
125
+ result.required[k] = (0, node_js_1.flattenNode)(prop, ctx);
126
+ }
127
+ ctx.path.pop();
128
+ }
129
+ entries.push([`${kind}Props`, result]);
130
+ };
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareStrictness = exports.checkBound = exports.flattenRange = exports.rangeIntersection = exports.isEqualityRange = exports.maxComparators = exports.minComparators = void 0;
4
+ const data_js_1 = require("../../utils/data.js");
5
+ const compose_js_1 = require("../compose.js");
6
+ exports.minComparators = {
7
+ ">": true,
8
+ ">=": true
9
+ };
10
+ exports.maxComparators = {
11
+ "<": true,
12
+ "<=": true
13
+ };
14
+ const isEqualityRange = (range) => "comparator" in range;
15
+ exports.isEqualityRange = isEqualityRange;
16
+ exports.rangeIntersection = (0, compose_js_1.composeIntersection)((l, r, state) => {
17
+ if ((0, exports.isEqualityRange)(l)) {
18
+ if ((0, exports.isEqualityRange)(r)) {
19
+ return l.limit === r.limit
20
+ ? (0, compose_js_1.equality)()
21
+ : state.addDisjoint("range", l, r);
22
+ }
23
+ return rangeAllows(r, l.limit) ? l : state.addDisjoint("range", l, r);
24
+ }
25
+ if ((0, exports.isEqualityRange)(r)) {
26
+ return rangeAllows(l, r.limit) ? r : state.addDisjoint("range", l, r);
27
+ }
28
+ const stricterMin = (0, exports.compareStrictness)("min", l.min, r.min);
29
+ const stricterMax = (0, exports.compareStrictness)("max", l.max, r.max);
30
+ if (stricterMin === "l") {
31
+ if (stricterMax === "r") {
32
+ return (0, exports.compareStrictness)("min", l.min, r.max) === "l"
33
+ ? state.addDisjoint("range", l, r)
34
+ : {
35
+ min: l.min,
36
+ max: r.max
37
+ };
38
+ }
39
+ return l;
40
+ }
41
+ if (stricterMin === "r") {
42
+ if (stricterMax === "l") {
43
+ return (0, exports.compareStrictness)("max", l.max, r.min) === "l"
44
+ ? state.addDisjoint("range", l, r)
45
+ : {
46
+ min: r.min,
47
+ max: l.max
48
+ };
49
+ }
50
+ return r;
51
+ }
52
+ return stricterMax === "l" ? l : stricterMax === "r" ? r : (0, compose_js_1.equality)();
53
+ });
54
+ const rangeAllows = (range, n) => (0, exports.isEqualityRange)(range)
55
+ ? n === range.limit
56
+ : minAllows(range.min, n) && maxAllows(range.max, n);
57
+ const minAllows = (min, n) => !min || n > min.limit || (n === min.limit && !isExclusive(min.comparator));
58
+ const maxAllows = (max, n) => !max || n < max.limit || (n === max.limit && !isExclusive(max.comparator));
59
+ const flattenRange = (entries, range, ctx) => {
60
+ const units = ctx.lastDomain === "string"
61
+ ? "characters"
62
+ : ctx.lastDomain === "object"
63
+ ? "items long"
64
+ : undefined;
65
+ if ((0, exports.isEqualityRange)(range)) {
66
+ return entries.push(["bound", units ? { ...range, units } : range]);
67
+ }
68
+ if (range.min) {
69
+ entries.push(["bound", units ? { ...range.min, units } : range.min]);
70
+ }
71
+ if (range.max) {
72
+ entries.push(["bound", units ? { ...range.max, units } : range.max]);
73
+ }
74
+ };
75
+ exports.flattenRange = flattenRange;
76
+ const checkBound = (bound, state) => comparatorCheckers[bound.comparator]((0, data_js_1.sizeOf)(state.data), bound.limit) ||
77
+ !state.problems.add("bound", bound);
78
+ exports.checkBound = checkBound;
79
+ const comparatorCheckers = {
80
+ "<": (size, limit) => size < limit,
81
+ ">": (size, limit) => size > limit,
82
+ "<=": (size, limit) => size <= limit,
83
+ ">=": (size, limit) => size >= limit,
84
+ "==": (size, limit) => size === limit
85
+ };
86
+ const compareStrictness = (kind, l, r) => !l
87
+ ? !r
88
+ ? "="
89
+ : "r"
90
+ : !r
91
+ ? "l"
92
+ : l.limit === r.limit
93
+ ? isExclusive(l.comparator)
94
+ ? isExclusive(r.comparator)
95
+ ? "="
96
+ : "l"
97
+ : isExclusive(r.comparator)
98
+ ? "r"
99
+ : "="
100
+ : kind === "min"
101
+ ? l.limit > r.limit
102
+ ? "l"
103
+ : "r"
104
+ : l.limit < r.limit
105
+ ? "l"
106
+ : "r";
107
+ exports.compareStrictness = compareStrictness;
108
+ const isExclusive = (comparator) => comparator.length === 1;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.regexIntersection = exports.checkRegex = exports.getRegex = void 0;
4
+ const compose_js_1 = require("../compose.js");
5
+ const collapsibleSet_js_1 = require("./collapsibleSet.js");
6
+ const regexCache = {};
7
+ const getRegex = (source) => {
8
+ if (!regexCache[source]) {
9
+ regexCache[source] = new RegExp(source);
10
+ }
11
+ return regexCache[source];
12
+ };
13
+ exports.getRegex = getRegex;
14
+ const checkRegex = (source, state) => (0, exports.getRegex)(source).test(state.data) ||
15
+ !state.problems.add("regex", `/${source}/`);
16
+ exports.checkRegex = checkRegex;
17
+ exports.regexIntersection = (0, compose_js_1.composeIntersection)((collapsibleSet_js_1.collapsibleListUnion));
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.literalSatisfiesRules = exports.precedenceMap = exports.flattenRules = exports.narrowableRulesIntersection = exports.rulesIntersection = void 0;
4
+ const generics_js_1 = require("../../utils/generics.js");
5
+ const compose_js_1 = require("../compose.js");
6
+ const class_js_1 = require("./class.js");
7
+ const collapsibleSet_js_1 = require("./collapsibleSet.js");
8
+ const divisor_js_1 = require("./divisor.js");
9
+ const props_js_1 = require("./props.js");
10
+ const range_js_1 = require("./range.js");
11
+ const regex_js_1 = require("./regex.js");
12
+ const rulesIntersection = (l, r, state) => "value" in l
13
+ ? "value" in r
14
+ ? l.value === r.value
15
+ ? (0, compose_js_1.equality)()
16
+ : state.addDisjoint("value", l.value, r.value)
17
+ : (0, exports.literalSatisfiesRules)(l.value, r, state)
18
+ ? l
19
+ : state.addDisjoint("leftAssignability", l, r)
20
+ : "value" in r
21
+ ? (0, exports.literalSatisfiesRules)(r.value, l, state)
22
+ ? r
23
+ : state.addDisjoint("rightAssignability", l, r)
24
+ : (0, exports.narrowableRulesIntersection)(l, r, state);
25
+ exports.rulesIntersection = rulesIntersection;
26
+ const narrowIntersection = (0, compose_js_1.composeIntersection)(collapsibleSet_js_1.collapsibleListUnion);
27
+ exports.narrowableRulesIntersection = (0, compose_js_1.composeKeyedIntersection)({
28
+ divisor: divisor_js_1.divisorIntersection,
29
+ regex: regex_js_1.regexIntersection,
30
+ props: props_js_1.propsIntersection,
31
+ class: class_js_1.classIntersection,
32
+ range: range_js_1.rangeIntersection,
33
+ narrow: narrowIntersection
34
+ }, { onEmpty: "bubble" });
35
+ const flattenRules = (rules, ctx) => {
36
+ const entries = [];
37
+ let k;
38
+ for (k in rules) {
39
+ ruleFlatteners[k](entries, rules[k], ctx);
40
+ }
41
+ // Some entries with the same precedence, e.g. morphs flattened from a list,
42
+ // rely on the fact that JS's builtin sort is stable to behave as expected
43
+ // when traversed:
44
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
45
+ return entries.sort((l, r) => exports.precedenceMap[l[0]] - exports.precedenceMap[r[0]]);
46
+ };
47
+ exports.flattenRules = flattenRules;
48
+ const ruleFlatteners = {
49
+ regex: (entries, rule) => {
50
+ for (const source of (0, generics_js_1.listFrom)(rule)) {
51
+ entries.push(["regex", source]);
52
+ }
53
+ },
54
+ divisor: (entries, rule) => {
55
+ entries.push(["divisor", rule]);
56
+ },
57
+ range: range_js_1.flattenRange,
58
+ class: (entries, rule) => {
59
+ entries.push(["class", rule]);
60
+ },
61
+ props: props_js_1.flattenProps,
62
+ narrow: (entries, rule) => {
63
+ for (const narrow of (0, generics_js_1.listFrom)(rule)) {
64
+ entries.push(["narrow", narrow]);
65
+ }
66
+ },
67
+ value: (entries, rule) => {
68
+ entries.push(["value", rule]);
69
+ }
70
+ };
71
+ exports.precedenceMap = {
72
+ // Config: Applies before any checks
73
+ config: -1,
74
+ // Critical: No other checks are performed if these fail
75
+ domain: 0,
76
+ value: 0,
77
+ domains: 0,
78
+ branches: 0,
79
+ switch: 0,
80
+ alias: 0,
81
+ class: 0,
82
+ // Shallow: All shallow checks will be performed even if one or more fail
83
+ regex: 1,
84
+ divisor: 1,
85
+ bound: 1,
86
+ // Prerequisite: These are deep checks with special priority, e.g. the
87
+ // length of a tuple, which causes other deep props not to be checked if it
88
+ // is invalid
89
+ prerequisiteProp: 2,
90
+ // Deep: Performed if all shallow checks pass, even if one or more deep checks fail
91
+ distilledProps: 3,
92
+ strictProps: 3,
93
+ requiredProp: 3,
94
+ optionalProp: 3,
95
+ indexProp: 3,
96
+ // Narrow: Only performed if all shallow and deep checks pass
97
+ narrow: 4,
98
+ // Morph: Only performed if all validation passes
99
+ morph: 5
100
+ };
101
+ const literalSatisfiesRules = (data, rules, state) => !state.type.scope.type(["node", { [state.domain]: rules }])(data).problems;
102
+ exports.literalSatisfiesRules = literalSatisfiesRules;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeUnboundableMessage = exports.writeDoubleRightBoundMessage = void 0;
4
+ const writeDoubleRightBoundMessage = (root) => `Expression ${root} must have at most one right bound`;
5
+ exports.writeDoubleRightBoundMessage = writeDoubleRightBoundMessage;
6
+ const writeUnboundableMessage = (root) => `Bounded expression ${root} must be a number, string or array`;
7
+ exports.writeUnboundableMessage = writeUnboundableMessage;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseConfigTuple = void 0;
4
+ const definition_js_1 = require("../definition.js");
5
+ /**
6
+ * @operator {@link parseConfigTuple | :}
7
+ * @docgenTable
8
+ * @tuple ["type", ":", config]
9
+ */
10
+ const parseConfigTuple = (def, ctx) => ({
11
+ node: ctx.type.scope.resolveTypeNode((0, definition_js_1.parseDefinition)(def[0], ctx)),
12
+ config: def[2]
13
+ });
14
+ exports.parseConfigTuple = parseConfigTuple;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.distributeFunctionToNode = exports.writeMalformedDistributableFunctionMessage = void 0;
4
+ const domains_js_1 = require("../../utils/domains.js");
5
+ const errors_js_1 = require("../../utils/errors.js");
6
+ const generics_js_1 = require("../../utils/generics.js");
7
+ const serialize_js_1 = require("../../utils/serialize.js");
8
+ const writeMalformedDistributableFunctionMessage = (def) => `Expected a Function or Record<Domain, Function> operand (${(0, serialize_js_1.stringify)(def)} was invalid)`;
9
+ exports.writeMalformedDistributableFunctionMessage = writeMalformedDistributableFunctionMessage;
10
+ const distributeFunctionToNode = (distributableFunction, node, ctx, ruleKey) => {
11
+ const domains = (0, generics_js_1.objectKeysOf)(node);
12
+ if (!(0, domains_js_1.hasDomain)(distributableFunction, "object")) {
13
+ return (0, errors_js_1.throwParseError)((0, exports.writeMalformedDistributableFunctionMessage)(distributableFunction));
14
+ }
15
+ const distributed = {};
16
+ if (typeof distributableFunction === "function") {
17
+ const domainFunction = {
18
+ [ruleKey]: distributableFunction
19
+ };
20
+ for (const domain of domains) {
21
+ distributed[domain] = domainFunction;
22
+ }
23
+ }
24
+ else {
25
+ for (const domain of domains) {
26
+ if (distributableFunction[domain] === undefined) {
27
+ continue;
28
+ }
29
+ const functionInDomain = {
30
+ [ruleKey]: distributableFunction[domain]
31
+ };
32
+ if (typeof functionInDomain[ruleKey] !== "function") {
33
+ return (0, errors_js_1.throwParseError)((0, exports.writeMalformedDistributableFunctionMessage)(functionInDomain));
34
+ }
35
+ distributed[domain] = functionInDomain;
36
+ }
37
+ }
38
+ return distributed;
39
+ };
40
+ exports.distributeFunctionToNode = distributeFunctionToNode;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeIndivisibleMessage = void 0;
4
+ const writeIndivisibleMessage = (root) => `Divisibility operand ${root} must be a number`;
5
+ exports.writeIndivisibleMessage = writeIndivisibleMessage;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeImplicitNeverMessage = exports.compileDisjointReasonsMessage = void 0;
4
+ const compose_js_1 = require("../../nodes/compose.js");
5
+ const generics_js_1 = require("../../utils/generics.js");
6
+ const compileDisjointReasonsMessage = (disjoints) => {
7
+ const paths = (0, generics_js_1.objectKeysOf)(disjoints);
8
+ if (paths.length === 1) {
9
+ const path = paths[0];
10
+ return `${path === "/" ? "" : `At ${path}: `}Intersection of ${compose_js_1.disjointDescriptionWriters[disjoints[path].kind](disjoints[path])} results in an unsatisfiable type`;
11
+ }
12
+ let message = `
13
+ "Intersection results in unsatisfiable types at the following paths:\n`;
14
+ for (const path in disjoints) {
15
+ message += ` ${path}: ${compose_js_1.disjointDescriptionWriters[disjoints[path].kind](disjoints[path])}\n`;
16
+ }
17
+ return message;
18
+ };
19
+ exports.compileDisjointReasonsMessage = compileDisjointReasonsMessage;
20
+ const writeImplicitNeverMessage = (path, operator, description) => `${path.length ? `At ${path}: ` : ""}${operator} ${description ? `${description} ` : ""}results in an unsatisfiable type`;
21
+ exports.writeImplicitNeverMessage = writeImplicitNeverMessage;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseKeyOfTuple = void 0;
4
+ const props_js_1 = require("../../nodes/rules/props.js");
5
+ const errors_js_1 = require("../../utils/errors.js");
6
+ const freeze_js_1 = require("../../utils/freeze.js");
7
+ const generics_js_1 = require("../../utils/generics.js");
8
+ const numericLiterals_js_1 = require("../../utils/numericLiterals.js");
9
+ const objectKinds_js_1 = require("../../utils/objectKinds.js");
10
+ const serialize_js_1 = require("../../utils/serialize.js");
11
+ const definition_js_1 = require("../definition.js");
12
+ const intersection_js_1 = require("./intersection.js");
13
+ const arrayIndexStringBranch = (0, freeze_js_1.deepFreeze)({
14
+ regex: numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher.source
15
+ });
16
+ const arrayIndexNumberBranch = (0, freeze_js_1.deepFreeze)({
17
+ range: { min: { comparator: ">=", limit: 0 } },
18
+ divisor: 1
19
+ });
20
+ const parseKeyOfTuple = (def, ctx) => {
21
+ const resolution = ctx.type.scope.resolveNode((0, definition_js_1.parseDefinition)(def[1], ctx));
22
+ const predicateKeys = (0, generics_js_1.objectKeysOf)(resolution).map((domain) => keysOfPredicate(domain, resolution[domain]));
23
+ const sharedKeys = sharedKeysOf(predicateKeys);
24
+ if (!sharedKeys.length) {
25
+ return (0, intersection_js_1.writeImplicitNeverMessage)(ctx.path, "keyof");
26
+ }
27
+ const keyNode = {};
28
+ for (const key of sharedKeys) {
29
+ const keyType = typeof key;
30
+ if (keyType === "string" ||
31
+ keyType === "number" ||
32
+ keyType === "symbol") {
33
+ keyNode[keyType] ??= [];
34
+ keyNode[keyType].push({ value: key });
35
+ }
36
+ else if (key === numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher) {
37
+ keyNode.string ??= [];
38
+ keyNode.string.push(arrayIndexStringBranch);
39
+ keyNode.number ??= [];
40
+ keyNode.number.push(arrayIndexNumberBranch);
41
+ }
42
+ else {
43
+ return (0, errors_js_1.throwInternalError)(`Unexpected keyof key '${(0, serialize_js_1.stringify)(key)}'`);
44
+ }
45
+ }
46
+ return Object.fromEntries(Object.entries(keyNode).map(([domain, branches]) => [
47
+ domain,
48
+ branches.length === 1 ? branches[0] : branches
49
+ ]));
50
+ };
51
+ exports.parseKeyOfTuple = parseKeyOfTuple;
52
+ const baseKeysByDomain = {
53
+ bigint: (0, generics_js_1.prototypeKeysOf)(0n),
54
+ boolean: (0, generics_js_1.prototypeKeysOf)(false),
55
+ null: [],
56
+ number: (0, generics_js_1.prototypeKeysOf)(0),
57
+ // TS doesn't include the Object prototype in keyof, so keyof object is never
58
+ object: [],
59
+ string: (0, generics_js_1.prototypeKeysOf)(""),
60
+ symbol: (0, generics_js_1.prototypeKeysOf)(Symbol()),
61
+ undefined: []
62
+ };
63
+ const keysOfPredicate = (domain, predicate) => domain !== "object" || predicate === true
64
+ ? baseKeysByDomain[domain]
65
+ : sharedKeysOf((0, generics_js_1.listFrom)(predicate).map((branch) => keysOfObjectBranch(branch)));
66
+ const sharedKeysOf = (keyBranches) => {
67
+ if (!keyBranches.length) {
68
+ return [];
69
+ }
70
+ let sharedKeys = keyBranches[0];
71
+ for (let i = 1; i < keyBranches.length; i++) {
72
+ // we can filter directly by equality here because the RegExp we're
73
+ // using will always be reference equal to
74
+ // wellFormedNonNegativeIntegerMatcher
75
+ sharedKeys = sharedKeys.filter((k) => keyBranches[i].includes(k));
76
+ }
77
+ return sharedKeys;
78
+ };
79
+ const keysOfObjectBranch = (branch) => {
80
+ const result = [];
81
+ if ("props" in branch) {
82
+ for (const key of Object.keys(branch.props)) {
83
+ if (key === props_js_1.mappedKeys.index) {
84
+ // if any number is a valid key push this RegExp
85
+ result.push(numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher);
86
+ }
87
+ else if (!result.includes(key)) {
88
+ result.push(key);
89
+ if (numericLiterals_js_1.wellFormedNonNegativeIntegerMatcher.test(key)) {
90
+ // allow numeric access to keys
91
+ result.push((0, numericLiterals_js_1.tryParseWellFormedInteger)(key, `Unexpectedly failed to parse an integer from key '${key}'`));
92
+ }
93
+ }
94
+ }
95
+ }
96
+ if ("class" in branch) {
97
+ const constructor = typeof branch.class === "string"
98
+ ? objectKinds_js_1.defaultObjectKinds[branch.class]
99
+ : branch.class;
100
+ for (const key of (0, generics_js_1.prototypeKeysOf)(constructor.prototype)) {
101
+ if (!result.includes(key)) {
102
+ result.push(key);
103
+ }
104
+ }
105
+ }
106
+ return result;
107
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeMalformedMorphExpressionMessage = exports.parseMorphTuple = void 0;
4
+ const branch_js_1 = require("../../nodes/branch.js");
5
+ const errors_js_1 = require("../../utils/errors.js");
6
+ const objectKinds_js_1 = require("../../utils/objectKinds.js");
7
+ const serialize_js_1 = require("../../utils/serialize.js");
8
+ const definition_js_1 = require("../definition.js");
9
+ const parseMorphTuple = (def, ctx) => {
10
+ if (typeof def[2] !== "function") {
11
+ return (0, errors_js_1.throwParseError)((0, exports.writeMalformedMorphExpressionMessage)(def[2]));
12
+ }
13
+ const node = (0, definition_js_1.parseDefinition)(def[0], ctx);
14
+ const resolution = ctx.type.scope.resolveTypeNode(node);
15
+ const morph = def[2];
16
+ ctx.type.includesMorph = true;
17
+ let domain;
18
+ const result = {};
19
+ for (domain in resolution) {
20
+ const predicate = resolution[domain];
21
+ if (predicate === true) {
22
+ result[domain] = { rules: {}, morph };
23
+ }
24
+ else if (typeof predicate === "object") {
25
+ result[domain] = (0, objectKinds_js_1.isArray)(predicate)
26
+ ? predicate.map((branch) => applyMorph(branch, morph))
27
+ : applyMorph(predicate, morph);
28
+ }
29
+ else {
30
+ (0, errors_js_1.throwInternalError)(`Unexpected predicate value for domain '${domain}': ${(0, serialize_js_1.stringify)(predicate)}`);
31
+ }
32
+ }
33
+ return result;
34
+ };
35
+ exports.parseMorphTuple = parseMorphTuple;
36
+ const applyMorph = (branch, morph) => (0, branch_js_1.isTransformationBranch)(branch)
37
+ ? {
38
+ ...branch,
39
+ morph: branch.morph
40
+ ? Array.isArray(branch.morph)
41
+ ? [...branch.morph, morph]
42
+ : [branch.morph, morph]
43
+ : morph
44
+ }
45
+ : {
46
+ rules: branch,
47
+ morph
48
+ };
49
+ const writeMalformedMorphExpressionMessage = (value) => `Morph expression requires a function following '|>' (was ${typeof value})`;
50
+ exports.writeMalformedMorphExpressionMessage = writeMalformedMorphExpressionMessage;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseNarrowTuple = void 0;
4
+ const node_js_1 = require("../../nodes/node.js");
5
+ const definition_js_1 = require("../definition.js");
6
+ const distributableFunction_js_1 = require("./distributableFunction.js");
7
+ const parseNarrowTuple = (def, ctx) => {
8
+ const inputNode = (0, definition_js_1.parseDefinition)(def[0], ctx);
9
+ const resolution = ctx.type.scope.resolveNode(inputNode);
10
+ const hasConfig = (0, node_js_1.isConfigNode)(resolution);
11
+ const typeNode = hasConfig ? resolution.node : resolution;
12
+ const result = (0, node_js_1.rootIntersection)(inputNode, (0, distributableFunction_js_1.distributeFunctionToNode)(def[2], typeNode, ctx, "narrow"), ctx.type);
13
+ return hasConfig
14
+ ? { config: resolution.config, node: result }
15
+ : result;
16
+ };
17
+ exports.parseNarrowTuple = parseNarrowTuple;
@@ -9,7 +9,9 @@ import type { BuiltinClass, inferObjectKind } from "../../utils/objectKinds.js";
9
9
  import type { inferTerminal } from "./ast.js";
10
10
  export type inferNode<node extends Node<$>, $ = {}> = node extends string ? inferTerminal<node, $> : node extends Node<$> ? inferResolution<node, $> extends infer result ? result extends BuiltinClass ? result : evaluateObjectOrFunction<result> : never : never;
11
11
  export type inferResolution<node extends Node<$>, $> = {
12
- [domain in keyof node]: inferPredicate<domain, node[domain], $>;
12
+ [domain in keyof node]: inferPredicate<
13
+ /** @ts-expect-error Some very odd inference behavior related to domain I can't resolve */
14
+ domain, node[domain], $>;
13
15
  }[keyof node];
14
16
  type inferPredicate<domain extends Domain, predicate extends Predicate, $> = predicate extends true ? inferDomain<domain> : inferBranch<domain, branchFrom<predicate>, $>;
15
17
  type branchFrom<predicate extends Predicate> = predicate extends List ? predicate[number] : predicate;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });