arktype 2.0.0-dev.1 → 2.0.0-dev.11

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 (221) hide show
  1. package/out/api.d.ts +6 -0
  2. package/out/api.js +5 -0
  3. package/out/ark.d.ts +15 -39
  4. package/out/ark.js +9 -18
  5. package/out/config.d.ts +1 -0
  6. package/out/config.js +2 -0
  7. package/out/generic.d.ts +21 -0
  8. package/out/generic.js +24 -0
  9. package/out/main.d.ts +6 -7
  10. package/out/main.js +4 -3
  11. package/out/match.d.ts +57 -34
  12. package/out/match.js +51 -17
  13. package/out/module.d.ts +12 -0
  14. package/out/module.js +3 -0
  15. package/out/parser/definition.d.ts +14 -14
  16. package/out/parser/definition.js +10 -13
  17. package/out/parser/generic.d.ts +5 -7
  18. package/out/parser/generic.js +7 -11
  19. package/out/parser/objectLiteral.d.ts +44 -18
  20. package/out/parser/objectLiteral.js +57 -51
  21. package/out/parser/semantic/bounds.d.ts +10 -8
  22. package/out/parser/semantic/bounds.js +0 -1
  23. package/out/parser/semantic/divisor.d.ts +5 -7
  24. package/out/parser/semantic/divisor.js +0 -1
  25. package/out/parser/semantic/infer.d.ts +24 -0
  26. package/out/parser/semantic/infer.js +1 -0
  27. package/out/parser/semantic/utils.d.ts +3 -7
  28. package/out/parser/semantic/utils.js +0 -1
  29. package/out/parser/semantic/validate.d.ts +16 -13
  30. package/out/parser/semantic/validate.js +1 -1
  31. package/out/parser/string/reduce/dynamic.d.ts +13 -13
  32. package/out/parser/string/reduce/dynamic.js +31 -26
  33. package/out/parser/string/reduce/shared.d.ts +14 -28
  34. package/out/parser/string/reduce/shared.js +4 -3
  35. package/out/parser/string/reduce/static.d.ts +27 -24
  36. package/out/parser/string/reduce/static.js +0 -1
  37. package/out/parser/string/shift/operand/date.d.ts +2 -2
  38. package/out/parser/string/shift/operand/date.js +4 -7
  39. package/out/parser/string/shift/operand/enclosed.d.ts +3 -4
  40. package/out/parser/string/shift/operand/enclosed.js +14 -14
  41. package/out/parser/string/shift/operand/genericArgs.d.ts +9 -10
  42. package/out/parser/string/shift/operand/genericArgs.js +6 -10
  43. package/out/parser/string/shift/operand/operand.d.ts +3 -4
  44. package/out/parser/string/shift/operand/operand.js +8 -12
  45. package/out/parser/string/shift/operand/unenclosed.d.ts +16 -21
  46. package/out/parser/string/shift/operand/unenclosed.js +24 -36
  47. package/out/parser/string/shift/operator/bounds.d.ts +8 -12
  48. package/out/parser/string/shift/operator/bounds.js +45 -56
  49. package/out/parser/string/shift/operator/divisor.d.ts +1 -3
  50. package/out/parser/string/shift/operator/divisor.js +1 -3
  51. package/out/parser/string/shift/operator/operator.d.ts +1 -2
  52. package/out/parser/string/shift/operator/operator.js +12 -19
  53. package/out/parser/string/shift/scanner.d.ts +2 -2
  54. package/out/parser/string/shift/scanner.js +14 -16
  55. package/out/parser/string/string.d.ts +8 -6
  56. package/out/parser/string/string.js +1 -3
  57. package/out/parser/tuple.d.ts +102 -43
  58. package/out/parser/tuple.js +119 -87
  59. package/out/scope.d.ts +44 -119
  60. package/out/scope.js +39 -209
  61. package/out/type.d.ts +43 -64
  62. package/out/type.js +30 -131
  63. package/package.json +12 -10
  64. package/__tests__/array.test.ts +0 -272
  65. package/__tests__/astUtils.test.ts +0 -17
  66. package/__tests__/badDefinitionType.test.ts +0 -51
  67. package/__tests__/basis.test.ts +0 -46
  68. package/__tests__/bounds.test.ts +0 -388
  69. package/__tests__/cast.test.ts +0 -32
  70. package/__tests__/completions.test.ts +0 -46
  71. package/__tests__/config.test.ts +0 -168
  72. package/__tests__/cyclic.test.ts +0 -144
  73. package/__tests__/dateLiteral.test.ts +0 -32
  74. package/__tests__/declared.test.ts +0 -123
  75. package/__tests__/discrimination.test.ts +0 -74
  76. package/__tests__/divisor.test.ts +0 -90
  77. package/__tests__/enclosed.test.ts +0 -93
  78. package/__tests__/examples.test.ts +0 -56
  79. package/__tests__/expressions.test.ts +0 -138
  80. package/__tests__/generateBenchData.ts +0 -89
  81. package/__tests__/generated/cyclic.ts +0 -3058
  82. package/__tests__/generic.test.ts +0 -294
  83. package/__tests__/group.test.ts +0 -72
  84. package/__tests__/hkt.test.ts +0 -22
  85. package/__tests__/imports.test.ts +0 -113
  86. package/__tests__/instanceof.test.ts +0 -102
  87. package/__tests__/intersection.test.ts +0 -104
  88. package/__tests__/jsdoc.test.ts +0 -64
  89. package/__tests__/keyTraversal.test.ts +0 -73
  90. package/__tests__/keyof.test.ts +0 -134
  91. package/__tests__/keywords.test.ts +0 -188
  92. package/__tests__/literal.test.ts +0 -51
  93. package/__tests__/match.test.ts +0 -34
  94. package/__tests__/methods.bench.ts +0 -22
  95. package/__tests__/morph.test.ts +0 -409
  96. package/__tests__/narrow.test.ts +0 -102
  97. package/__tests__/nodeDefinitions.test.ts +0 -190
  98. package/__tests__/object.bench.ts +0 -28
  99. package/__tests__/objectLiteral.test.ts +0 -300
  100. package/__tests__/operand.bench.ts +0 -45
  101. package/__tests__/operator.bench.ts +0 -130
  102. package/__tests__/regex.test.ts +0 -58
  103. package/__tests__/scope.bench.ts +0 -39
  104. package/__tests__/scope.test.ts +0 -140
  105. package/__tests__/string.test.ts +0 -48
  106. package/__tests__/submodule.test.ts +0 -99
  107. package/__tests__/this.test.ts +0 -57
  108. package/__tests__/thunk.test.ts +0 -80
  109. package/__tests__/traverse.test.ts +0 -119
  110. package/__tests__/tsGenerics.test.ts +0 -12
  111. package/__tests__/typeMethods.test.ts +0 -69
  112. package/__tests__/typeReference.test.ts +0 -39
  113. package/__tests__/unenclosed.test.ts +0 -120
  114. package/__tests__/union.test.ts +0 -147
  115. package/ark.ts +0 -91
  116. package/main.ts +0 -18
  117. package/match.ts +0 -116
  118. package/out/ark.d.ts.map +0 -1
  119. package/out/ark.js.map +0 -1
  120. package/out/arkConfig.d.ts +0 -2
  121. package/out/arkConfig.d.ts.map +0 -1
  122. package/out/arkConfig.js +0 -10
  123. package/out/arkConfig.js.map +0 -1
  124. package/out/main.d.ts.map +0 -1
  125. package/out/main.js.map +0 -1
  126. package/out/match.d.ts.map +0 -1
  127. package/out/match.js.map +0 -1
  128. package/out/parser/definition.d.ts.map +0 -1
  129. package/out/parser/definition.js.map +0 -1
  130. package/out/parser/generic.d.ts.map +0 -1
  131. package/out/parser/generic.js.map +0 -1
  132. package/out/parser/objectLiteral.d.ts.map +0 -1
  133. package/out/parser/objectLiteral.js.map +0 -1
  134. package/out/parser/semantic/bounds.d.ts.map +0 -1
  135. package/out/parser/semantic/bounds.js.map +0 -1
  136. package/out/parser/semantic/divisor.d.ts.map +0 -1
  137. package/out/parser/semantic/divisor.js.map +0 -1
  138. package/out/parser/semantic/intersections.d.ts +0 -14
  139. package/out/parser/semantic/intersections.d.ts.map +0 -1
  140. package/out/parser/semantic/intersections.js +0 -2
  141. package/out/parser/semantic/intersections.js.map +0 -1
  142. package/out/parser/semantic/semantic.d.ts +0 -33
  143. package/out/parser/semantic/semantic.d.ts.map +0 -1
  144. package/out/parser/semantic/semantic.js +0 -2
  145. package/out/parser/semantic/semantic.js.map +0 -1
  146. package/out/parser/semantic/utils.d.ts.map +0 -1
  147. package/out/parser/semantic/utils.js.map +0 -1
  148. package/out/parser/semantic/validate.d.ts.map +0 -1
  149. package/out/parser/semantic/validate.js.map +0 -1
  150. package/out/parser/shared.d.ts +0 -54
  151. package/out/parser/shared.d.ts.map +0 -1
  152. package/out/parser/shared.js +0 -47
  153. package/out/parser/shared.js.map +0 -1
  154. package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
  155. package/out/parser/string/reduce/dynamic.js.map +0 -1
  156. package/out/parser/string/reduce/shared.d.ts.map +0 -1
  157. package/out/parser/string/reduce/shared.js.map +0 -1
  158. package/out/parser/string/reduce/static.d.ts.map +0 -1
  159. package/out/parser/string/reduce/static.js.map +0 -1
  160. package/out/parser/string/shift/operand/date.d.ts.map +0 -1
  161. package/out/parser/string/shift/operand/date.js.map +0 -1
  162. package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
  163. package/out/parser/string/shift/operand/enclosed.js.map +0 -1
  164. package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
  165. package/out/parser/string/shift/operand/genericArgs.js.map +0 -1
  166. package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
  167. package/out/parser/string/shift/operand/operand.js.map +0 -1
  168. package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
  169. package/out/parser/string/shift/operand/unenclosed.js.map +0 -1
  170. package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
  171. package/out/parser/string/shift/operator/bounds.js.map +0 -1
  172. package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
  173. package/out/parser/string/shift/operator/divisor.js.map +0 -1
  174. package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
  175. package/out/parser/string/shift/operator/operator.js.map +0 -1
  176. package/out/parser/string/shift/scanner.d.ts.map +0 -1
  177. package/out/parser/string/shift/scanner.js.map +0 -1
  178. package/out/parser/string/string.d.ts.map +0 -1
  179. package/out/parser/string/string.js.map +0 -1
  180. package/out/parser/tuple.d.ts.map +0 -1
  181. package/out/parser/tuple.js.map +0 -1
  182. package/out/scope.d.ts.map +0 -1
  183. package/out/scope.js.map +0 -1
  184. package/out/test.d.ts +0 -2
  185. package/out/test.d.ts.map +0 -1
  186. package/out/test.js +0 -7
  187. package/out/test.js.map +0 -1
  188. package/out/tsconfig.build.tsbuildinfo +0 -1
  189. package/out/type.d.ts.map +0 -1
  190. package/out/type.js.map +0 -1
  191. package/out/util.d.ts +0 -19
  192. package/out/util.d.ts.map +0 -1
  193. package/out/util.js +0 -7
  194. package/out/util.js.map +0 -1
  195. package/parser/definition.ts +0 -159
  196. package/parser/generic.ts +0 -68
  197. package/parser/objectLiteral.ts +0 -197
  198. package/parser/semantic/bounds.ts +0 -61
  199. package/parser/semantic/divisor.ts +0 -13
  200. package/parser/semantic/intersections.ts +0 -46
  201. package/parser/semantic/semantic.ts +0 -144
  202. package/parser/semantic/utils.ts +0 -26
  203. package/parser/semantic/validate.ts +0 -109
  204. package/parser/shared.ts +0 -152
  205. package/parser/string/reduce/dynamic.ts +0 -196
  206. package/parser/string/reduce/shared.ts +0 -101
  207. package/parser/string/reduce/static.ts +0 -298
  208. package/parser/string/shift/operand/date.ts +0 -54
  209. package/parser/string/shift/operand/enclosed.ts +0 -118
  210. package/parser/string/shift/operand/genericArgs.ts +0 -127
  211. package/parser/string/shift/operand/operand.ts +0 -48
  212. package/parser/string/shift/operand/unenclosed.ts +0 -268
  213. package/parser/string/shift/operator/bounds.ts +0 -264
  214. package/parser/string/shift/operator/divisor.ts +0 -36
  215. package/parser/string/shift/operator/operator.ts +0 -82
  216. package/parser/string/shift/scanner.ts +0 -209
  217. package/parser/string/string.ts +0 -90
  218. package/parser/tuple.ts +0 -474
  219. package/scope.ts +0 -574
  220. package/type.ts +0 -347
  221. package/util.ts +0 -36
@@ -1,66 +1,72 @@
1
- import { keywords, schema } from "@arktype/schema";
2
- import { printable, throwParseError } from "@arktype/util";
3
- import { parseEntry } from "./shared.js";
4
- const stringAndSymbolicEntriesOf = (o) => [
5
- ...Object.entries(o),
6
- ...Object.getOwnPropertySymbols(o).map((k) => [k, o[k]])
7
- ];
1
+ import { append, printable, spliterate, stringAndSymbolicEntriesOf, throwParseError } from "@arktype/util";
2
+ import { Scanner } from "./string/shift/scanner.js";
8
3
  export const parseObjectLiteral = (def, ctx) => {
9
- const required = [];
10
- const optional = [];
4
+ let spread;
5
+ const structure = {};
11
6
  // We only allow a spread operator to be used as the first key in an object
12
7
  // because to match JS behavior any keys before the spread are overwritten
13
8
  // by the values in the target object, so there'd be no useful purpose in having it
14
9
  // anywhere except for the beginning.
15
- // Discussion in ArkType Discord:
16
- // https://discord.com/channels/957797212103016458/1103023445035462678/1182814502471860334
17
- let hasSeenFirstKey = false;
18
- const entries = stringAndSymbolicEntriesOf(def);
19
- for (const entry of entries) {
20
- const result = parseEntry(entry);
21
- if (result.kind === "spread") {
22
- if (hasSeenFirstKey) {
23
- return throwParseError("Spread operator may only be used as the first key in an object");
10
+ const parsedEntries = stringAndSymbolicEntriesOf(def).map(parseEntry);
11
+ if (parsedEntries[0]?.kind === "spread") {
12
+ // remove the spread entry so we can iterate over the remaining entries
13
+ // expecting non-spread entries
14
+ const spreadEntry = parsedEntries.shift();
15
+ const spreadNode = ctx.$.parse(spreadEntry.value, ctx);
16
+ if (!spreadNode.hasKind("intersection") || !spreadNode.structure) {
17
+ return throwParseError(writeInvalidSpreadTypeMessage(typeof spreadEntry.value === "string" ?
18
+ spreadEntry.value
19
+ : printable(spreadEntry.value)));
20
+ }
21
+ spread = spreadNode.structure;
22
+ }
23
+ for (const entry of parsedEntries) {
24
+ if (entry.kind === "spread")
25
+ return throwParseError(nonLeadingSpreadError);
26
+ if (entry.kind === "index") {
27
+ // handle key parsing first to match type behavior
28
+ const key = ctx.$.parse(entry.inner, ctx);
29
+ const value = ctx.$.parse(entry.value, ctx);
30
+ // extract enumerable named props from the index signature
31
+ const [enumerable, nonEnumerable] = spliterate(key.branches, (k) => k.hasKind("unit"));
32
+ if (enumerable.length) {
33
+ structure.required = append(structure.required, enumerable.map(k => ctx.$.node("required", { key: k.unit, value })));
34
+ if (nonEnumerable.length) {
35
+ structure.index = append(structure.index, ctx.$.node("index", { index: nonEnumerable, value }));
36
+ }
24
37
  }
25
- const spreadNode = ctx.scope.parse(result.innerValue, ctx);
26
- if (spreadNode.kind !== "intersection" ||
27
- !spreadNode.extends(keywords.object)) {
28
- return throwParseError(writeInvalidSpreadTypeMessage(printable(result.innerValue)));
38
+ else {
39
+ structure.index = append(structure.index, ctx.$.node("index", { index: key, value }));
29
40
  }
30
- // For each key on spreadNode, add it to our object.
31
- // We filter out keys from the spreadNode that will be defined later on this same object
32
- // because the currently parsed definition will overwrite them.
33
- const requiredEntriesFromSpread = (spreadNode.required ?? []).filter((e) => !entries.some(([k]) => k === e.key));
34
- const optionalEntriesFromSpread = (spreadNode.optional ?? []).filter((e) => !entries.some(([k]) => k === e.key));
35
- required.push(...requiredEntriesFromSpread);
36
- optional.push(...optionalEntriesFromSpread);
37
- continue;
38
- }
39
- ctx.path.push(`${typeof result.innerKey === "symbol"
40
- ? `[${printable(result.innerKey)}]`
41
- : result.innerKey}`);
42
- const valueNode = ctx.scope.parse(result.innerValue, ctx);
43
- if (result.kind === "optional") {
44
- optional.push({
45
- key: result.innerKey,
46
- value: valueNode
47
- });
48
41
  }
49
42
  else {
50
- required.push({
51
- key: result.innerKey,
52
- value: valueNode
43
+ const value = ctx.$.parse(entry.value, ctx);
44
+ structure[entry.kind] = append(structure[entry.kind], {
45
+ key: entry.inner,
46
+ value
53
47
  });
54
48
  }
55
- ctx.path.pop();
56
- hasSeenFirstKey ||= true;
57
49
  }
58
- return schema({
59
- basis: "object",
60
- required,
61
- optional
50
+ const structureNode = ctx.$.node("structure", structure);
51
+ return ctx.$.schema({
52
+ domain: "object",
53
+ structure: spread?.merge(structureNode) ?? structureNode
62
54
  });
63
55
  };
64
- export const writeInvalidPropertyKeyMessage = (indexDef) => `Indexed key definition '${indexDef}' must be a string, number or symbol`;
56
+ export const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
57
+ export const parseEntry = (entry) => Object.assign(parseKey(entry[0]), { value: entry[1] });
58
+ const parseKey = (key) => typeof key === "symbol" ? { inner: key, kind: "required" }
59
+ : key.at(-1) === "?" ?
60
+ key.at(-2) === Scanner.escapeToken ?
61
+ { inner: `${key.slice(0, -2)}?`, kind: "required" }
62
+ : {
63
+ inner: key.slice(0, -1),
64
+ kind: "optional"
65
+ }
66
+ : key[0] === "[" && key.at(-1) === "]" ?
67
+ { inner: key.slice(1, -1), kind: "index" }
68
+ : key[0] === Scanner.escapeToken && key[1] === "[" && key.at(-1) === "]" ?
69
+ { inner: key.slice(1), kind: "required" }
70
+ : key === "..." ? { inner: "...", kind: "spread" }
71
+ : { inner: key === "\\..." ? "..." : key, kind: "required" };
65
72
  export const writeInvalidSpreadTypeMessage = (def) => `Spread operand must resolve to an object literal type (was ${def})`;
66
- //# sourceMappingURL=objectLiteral.js.map
@@ -1,13 +1,15 @@
1
- import type { NumericallyBoundable } from "@arktype/schema";
2
- import type { ErrorMessage } from "@arktype/util";
3
- import type { Comparator, InvertedComparators, LimitLiteral } from "../string/reduce/shared.js";
4
- import type { BoundExpressionKind, writeInvalidLimitMessage, writeUnboundableMessage } from "../string/shift/operator/bounds.js";
5
- import type { inferAstBase } from "./semantic.js";
1
+ import type { LimitLiteral, writeUnboundableMessage } from "@arktype/schema";
2
+ import type { ErrorMessage, array } from "@arktype/util";
3
+ import type { Comparator } from "../string/reduce/shared.js";
4
+ import type { BoundExpressionKind, writeInvalidLimitMessage } from "../string/shift/operator/bounds.js";
5
+ import type { inferAstIn } from "./infer.js";
6
6
  import type { astToString } from "./utils.js";
7
7
  import type { validateAst } from "./validate.js";
8
- export type validateRange<l, comparator extends Comparator, r, $, args> = l extends LimitLiteral ? validateBound<r, InvertedComparators[comparator], l, "left", $, args> : l extends [infer leftAst, Comparator, unknown] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, "right", $, args>;
9
- export type validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> = inferAstBase<boundedAst, $, args> extends infer bounded ? [bounded] extends [NumericallyBoundable] ? limit extends number ? validateAst<boundedAst, $, args> : ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>> : bounded extends Date ? validateAst<boundedAst, $, args> : ErrorMessage<writeUnboundableMessage<astToString<boundKind extends "left" ? boundedAst[0 & keyof boundedAst] : boundedAst>>> : never;
8
+ export type validateRange<l, comparator extends Comparator, r, $, args> = l extends LimitLiteral ? validateBound<r, comparator, l, "left", $, args> : l extends [infer leftAst, Comparator, unknown] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, "right", $, args>;
9
+ export type validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> = inferAstIn<boundedAst, $, args> extends infer bounded ? isNumericallyBoundable<bounded> extends true ? limit extends number ? validateAst<boundedAst, $, args> : ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>> : bounded extends Date ? validateAst<boundedAst, $, args> : ErrorMessage<writeUnboundableMessage<astToString<boundKind extends "left" ? boundedAst[0 & keyof boundedAst] : boundedAst>>> : never;
10
+ type isNumericallyBoundable<bounded> = [
11
+ bounded
12
+ ] extends [number] ? true : [bounded] extends [string] ? true : [bounded] extends [array] ? true : false;
10
13
  export declare const writeDoubleRightBoundMessage: <root extends string>(root: root) => `Expression ${root} must have at most one right bound`;
11
14
  type writeDoubleRightBoundMessage<root extends string> = `Expression ${root} must have at most one right bound`;
12
15
  export {};
13
- //# sourceMappingURL=bounds.d.ts.map
@@ -1,2 +1 @@
1
1
  export const writeDoubleRightBoundMessage = (root) => `Expression ${root} must have at most one right bound`;
2
- //# sourceMappingURL=bounds.js.map
@@ -1,9 +1,7 @@
1
- import type { writeIndivisibleMessage } from "@arktype/schema";
1
+ import type { Root, writeIndivisibleMessage } from "@arktype/schema";
2
2
  import type { ErrorMessage } from "@arktype/util";
3
- import type { inferAstBase } from "./semantic.js";
4
- import type { astToString } from "./utils.js";
3
+ import type { inferAstIn } from "./infer.js";
5
4
  import type { validateAst } from "./validate.js";
6
- export type validateDivisor<l, $, args> = isDivisible<inferAstBase<l, $, args>> extends true ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<astToString<l>>>;
7
- type isDivisible<data> = [data] extends [number] ? true : false;
8
- export {};
9
- //# sourceMappingURL=divisor.d.ts.map
5
+ export type validateDivisor<l, $, args> = inferAstIn<l, $, args> extends infer data ? [
6
+ data
7
+ ] extends [number] ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<Root<data>>> : never;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=divisor.js.map
@@ -0,0 +1,24 @@
1
+ import type { Date, DateLiteral, GenericProps, LimitLiteral, RegexLiteral, constrain, distillIn, inferIntersection, normalizeLimit, string } from "@arktype/schema";
2
+ import type { BigintLiteral, array } from "@arktype/util";
3
+ import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.js";
4
+ import type { inferDefinition } from "../definition.js";
5
+ import type { Comparator, MinComparator } from "../string/reduce/shared.js";
6
+ import type { StringLiteral } from "../string/shift/operand/enclosed.js";
7
+ export type inferAstRoot<ast, $, args> = inferConstrainableAst<ast, $, args>;
8
+ export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
9
+ export type inferConstrainableAst<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : ast extends string ? inferTerminal<ast, $, args> : never;
10
+ export type GenericInstantiationAst<generic extends GenericProps = GenericProps, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
11
+ export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? inferDefinition<generic["def"], generic["$"]["t"] extends UnparsedScope ? $ : generic["$"]["t"], {
12
+ [i in keyof generic["params"] & `${number}` as generic["params"][i]]: inferConstrainableAst<argAsts[i & keyof argAsts], $, args>;
13
+ }> : ast[1] extends "[]" ? inferConstrainableAst<ast[0], $, args>[] : ast[1] extends "|" ? inferConstrainableAst<ast[0], $, args> | inferConstrainableAst<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferConstrainableAst<ast[0], $, args>, inferConstrainableAst<ast[2], $, args>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferConstrainableAst<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferConstrainableAst<ast[0], $, args>, ast[1], ast[2]> : ast[1] extends "%" ? constrain<inferConstrainableAst<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferConstrainableAst<ast[1], $, args> : never;
14
+ export type constrainBound<constrainableIn, comparator extends Comparator, limit> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : constrain<constrainableIn, "exactLength", limit & number> : constrain<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
15
+ rule: normalizeLimit<limit>;
16
+ exclusive: comparator extends ">" | "<" ? true : false;
17
+ }> : never;
18
+ export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
19
+ export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
20
+ export type PostfixOperator = "[]";
21
+ export type PostfixExpression<operator extends PostfixOperator = PostfixOperator, operand = unknown> = readonly [operand, operator];
22
+ export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@";
23
+ export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
24
+ export type inferTerminal<token extends string, $, args> = token extends keyof args | keyof $ ? resolve<token, $, args> : `#${token}` extends keyof $ ? resolve<`#${token}`, $, args> : token extends StringLiteral<infer text> ? text : token extends `${infer n extends number}` ? n : token extends BigintLiteral<infer b> ? b : token extends RegexLiteral<infer source> ? string.matching<source> : token extends DateLiteral<infer source> ? Date.literal<source> : tryInferSubmoduleReference<$, token>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,4 @@
1
- import type { List, Stringifiable } from "@arktype/util";
1
+ import type { Stringifiable } from "@arktype/util";
2
2
  import type { Comparator } from "../string/reduce/shared.js";
3
- import type { InfixExpression, PostfixExpression } from "./semantic.js";
4
- export type astToString<ast> = `'${astToStringRecurse<ast>}'`;
5
- type astToStringRecurse<ast> = ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${groupAst<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${groupAst<l>}${operator}${groupAst<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
6
- type groupAst<ast> = ast extends List ? ast[1] extends "[]" ? astToStringRecurse<ast> : `(${astToStringRecurse<ast>})` : astToStringRecurse<ast>;
7
- export {};
8
- //# sourceMappingURL=utils.d.ts.map
3
+ import type { InfixExpression, PostfixExpression } from "./infer.js";
4
+ export type astToString<ast> = ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${astToString<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${astToString<l>} ${operator} ${astToString<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=utils.js.map
@@ -1,24 +1,27 @@
1
- import type { BigintLiteral, Completion, ErrorMessage, NumberLiteral, writeMalformedNumericLiteralMessage } from "@arktype/util";
2
- import type { Module } from "../../scope.js";
3
- import type { GenericProps } from "../../type.js";
1
+ import type { arkKind, GenericProps, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@arktype/schema";
2
+ import type { anyOrNever, BigintLiteral, charsAfterFirst, Completion, ErrorMessage, writeMalformedNumericLiteralMessage } from "@arktype/util";
4
3
  import type { Comparator } from "../string/reduce/shared.js";
5
4
  import type { writeInvalidGenericArgsMessage } from "../string/shift/operand/genericArgs.js";
6
- import type { writeMissingSubmoduleAccessMessage } from "../string/shift/operand/unenclosed.js";
7
5
  import type { parseString } from "../string/string.js";
8
6
  import type { validateRange } from "./bounds.js";
9
7
  import type { validateDivisor } from "./divisor.js";
10
- import type { GenericInstantiationAst, InfixExpression, PostfixExpression } from "./semantic.js";
8
+ import type { GenericInstantiationAst, InfixExpression, PostfixExpression } from "./infer.js";
11
9
  import type { astToString } from "./utils.js";
12
- export type validateAst<ast, $, args> = ast extends string ? validateStringAst<ast, $> : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : undefined : ast extends readonly ["keyof", infer operand] ? validateAst<operand, $, args> : ast extends GenericInstantiationAst ? validateGenericArgs<ast["2"], $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>>;
10
+ export type validateAst<ast, $, args> = ast extends string ? validateStringAst<ast, $> : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : undefined : ast extends readonly ["keyof", infer operand] ? validateAst<operand, $, args> : ast extends GenericInstantiationAst ? validateGenericArgs<ast[2], $, args> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
11
+ ast: ast;
12
+ };
13
13
  type writeUnexpectedExpressionMessage<expression extends string> = `Unexpectedly failed to parse the expression resulting from ${expression}`;
14
- type validateGenericArgs<argAsts extends unknown[], $, args> = argAsts extends [
15
- infer head,
16
- ...infer tail
17
- ] ? validateAst<head, $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateGenericArgs<tail, $, args> : undefined;
14
+ type validateGenericArgs<argAsts extends unknown[], $, args> = argAsts extends [infer head, ...infer tail] ? validateAst<head, $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateGenericArgs<tail, $, args> : undefined;
18
15
  export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => `${expression} results in an unsatisfiable type`;
19
16
  export type writeUnsatisfiableExpressionError<expression extends string> = `${expression} results in an unsatisfiable type`;
20
- type validateStringAst<def extends string, $> = def extends NumberLiteral<infer value> ? number extends value ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral<infer value> ? bigint extends value ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : def extends keyof $ ? $[def] extends null ? def : $[def] extends GenericProps ? ErrorMessage<writeInvalidGenericArgsMessage<def, $[def]["parameters"], []>> : $[def] extends Module ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
21
- export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends infer result extends ErrorMessage ? result extends Completion<infer text> ? text : result : def;
17
+ export declare const writePrefixedPrivateReferenceMessage: <def extends `#${string}`>(def: def) => `Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`;
18
+ export type writePrefixedPrivateReferenceMessage<def extends PrivateDeclaration> = `Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`;
19
+ type validateStringAst<def extends string, $> = def extends `${infer n extends number}` ? number extends n ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral<infer b> ? bigint extends b ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : maybeExtractAlias<def, $> extends infer alias extends keyof $ ? [
20
+ $[alias]
21
+ ] extends [anyOrNever] ? def : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : $[alias] extends GenericProps ? ErrorMessage<writeInvalidGenericArgsMessage<def, $[alias]["params"], []>> : $[alias] extends {
22
+ [arkKind]: "module";
23
+ } ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
24
+ export type maybeExtractAlias<def extends string, $> = def extends keyof $ ? def : `#${def}` extends keyof $ ? `#${def}` : null;
25
+ export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
22
26
  type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateAst<ast[2], $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : undefined;
23
27
  export {};
24
- //# sourceMappingURL=validate.d.ts.map
@@ -1,2 +1,2 @@
1
1
  export const writeUnsatisfiableExpressionError = (expression) => `${expression} results in an unsatisfiable type`;
2
- //# sourceMappingURL=validate.js.map
2
+ export const writePrefixedPrivateReferenceMessage = (def) => `Private type references should not include '#'. Use '${def.slice(1)}' instead.`;
@@ -1,32 +1,33 @@
1
- import type { TypeNode } from "@arktype/schema";
1
+ import type { BaseRoot, LimitLiteral } from "@arktype/schema";
2
2
  import { type requireKeys } from "@arktype/util";
3
3
  import type { ParseContext } from "../../../scope.js";
4
+ import type { InfixOperator } from "../../semantic/infer.js";
4
5
  import { Scanner } from "../shift/scanner.js";
5
- import { type Comparator, type LimitLiteral, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.js";
6
+ import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.js";
6
7
  type BranchState = {
7
8
  prefixes: StringifiablePrefixOperator[];
8
- leftBound?: OpenLeftBound;
9
- "&"?: TypeNode;
10
- "|"?: TypeNode;
9
+ leftBound: OpenLeftBound | null;
10
+ intersection: BaseRoot | null;
11
+ union: BaseRoot | null;
11
12
  };
12
13
  export type DynamicStateWithRoot = requireKeys<DynamicState, "root">;
13
14
  export declare class DynamicState {
14
15
  readonly ctx: ParseContext;
15
16
  readonly scanner: Scanner;
16
- root: TypeNode | undefined;
17
+ root: BaseRoot<any> | undefined;
17
18
  branches: BranchState;
18
19
  finalizer: Scanner.FinalizingLookahead | undefined;
19
20
  groups: BranchState[];
20
21
  constructor(def: string, ctx: ParseContext);
21
22
  error(message: string): never;
22
23
  hasRoot(): this is DynamicStateWithRoot;
24
+ setRoot(root: BaseRoot): void;
23
25
  unsetRoot(): this["root"];
24
- constrainRoot(...args: Parameters<TypeNode["constrain"]>): void;
25
- setRoot(root: TypeNode): void;
26
- finalize(finalizer: Scanner.FinalizingLookahead): undefined;
27
- reduceLeftBound(limit: LimitLiteral, comparator: Comparator): undefined;
26
+ constrainRoot(...args: Parameters<BaseRoot<any>["constrain"]>): void;
27
+ finalize(finalizer: Scanner.FinalizingLookahead): void;
28
+ reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void;
28
29
  finalizeBranches(): void;
29
- finalizeGroup(): undefined;
30
+ finalizeGroup(): void;
30
31
  addPrefix(prefix: StringifiablePrefixOperator): void;
31
32
  applyPrefixes(): void;
32
33
  pushRootToBranch(token: "|" | "&"): void;
@@ -35,8 +36,7 @@ export declare class DynamicState {
35
36
  parseOperand(): void;
36
37
  private assertRangeUnset;
37
38
  reduceGroupOpen(): void;
38
- previousOperator(): ">" | ">=" | "|" | "&" | "keyof" | undefined;
39
+ previousOperator(): MinComparator | StringifiablePrefixOperator | InfixOperator | undefined;
39
40
  shiftedByOne(): this;
40
41
  }
41
42
  export {};
42
- //# sourceMappingURL=dynamic.d.ts.map
@@ -7,9 +7,13 @@ import { invertedComparators, minComparators, writeMultipleLeftBoundsMessage, wr
7
7
  export class DynamicState {
8
8
  ctx;
9
9
  scanner;
10
+ // set root type to `any` so that all constraints can be applied
10
11
  root;
11
12
  branches = {
12
- prefixes: []
13
+ prefixes: [],
14
+ leftBound: null,
15
+ intersection: null,
16
+ union: null
13
17
  };
14
18
  finalizer;
15
19
  groups = [];
@@ -23,29 +27,27 @@ export class DynamicState {
23
27
  hasRoot() {
24
28
  return this.root !== undefined;
25
29
  }
30
+ setRoot(root) {
31
+ this.root = root;
32
+ }
26
33
  unsetRoot() {
27
34
  const value = this.root;
28
35
  this.root = undefined;
29
36
  return value;
30
37
  }
31
38
  constrainRoot(...args) {
32
- this.root = this.root.constrain(...args);
33
- }
34
- setRoot(root) {
35
- this.root = root;
39
+ this.root = this.root.constrain(args[0], args[1]);
36
40
  }
37
41
  finalize(finalizer) {
38
- if (this.groups.length) {
42
+ if (this.groups.length)
39
43
  return this.error(writeUnclosedGroupMessage(")"));
40
- }
41
44
  this.finalizeBranches();
42
45
  this.finalizer = finalizer;
43
46
  }
44
47
  reduceLeftBound(limit, comparator) {
45
48
  const invertedComparator = invertedComparators[comparator];
46
- if (!isKeyOf(invertedComparator, minComparators)) {
49
+ if (!isKeyOf(invertedComparator, minComparators))
47
50
  return this.error(writeUnpairableComparatorMessage(comparator));
48
- }
49
51
  if (this.branches.leftBound) {
50
52
  return this.error(writeMultipleLeftBoundsMessage(this.branches.leftBound.limit, this.branches.leftBound.comparator, limit, invertedComparator));
51
53
  }
@@ -56,24 +58,22 @@ export class DynamicState {
56
58
  }
57
59
  finalizeBranches() {
58
60
  this.assertRangeUnset();
59
- if (this.branches["|"]) {
61
+ if (this.branches.union) {
60
62
  this.pushRootToBranch("|");
61
- this.root = this.branches["|"];
63
+ this.root = this.branches.union;
62
64
  }
63
- else if (this.branches["&"]) {
65
+ else if (this.branches.intersection) {
64
66
  this.pushRootToBranch("&");
65
- this.root = this.branches["&"];
67
+ this.root = this.branches.intersection;
66
68
  }
67
- else {
69
+ else
68
70
  this.applyPrefixes();
69
- }
70
71
  }
71
72
  finalizeGroup() {
72
73
  this.finalizeBranches();
73
74
  const topBranchState = this.groups.pop();
74
- if (!topBranchState) {
75
+ if (!topBranchState)
75
76
  return this.error(writeUnmatchedGroupCloseMessage(this.scanner.unscanned));
76
- }
77
77
  this.branches = topBranchState;
78
78
  }
79
79
  addPrefix(prefix) {
@@ -83,8 +83,8 @@ export class DynamicState {
83
83
  while (this.branches.prefixes.length) {
84
84
  const lastPrefix = this.branches.prefixes.pop();
85
85
  this.root =
86
- lastPrefix === "keyof"
87
- ? this.root.keyof()
86
+ lastPrefix === "keyof" ?
87
+ this.root.keyof()
88
88
  : throwInternalError(`Unexpected prefix '${lastPrefix}'`);
89
89
  }
90
90
  }
@@ -92,11 +92,12 @@ export class DynamicState {
92
92
  this.assertRangeUnset();
93
93
  this.applyPrefixes();
94
94
  const root = this.root;
95
- this.branches["&"] = this.branches["&"]?.and(root) ?? root;
95
+ this.branches.intersection = this.branches.intersection?.and(root) ?? root;
96
96
  if (token === "|") {
97
- this.branches["|"] =
98
- this.branches["|"]?.or(this.branches["&"]) ?? this.branches["&"];
99
- delete this.branches["&"];
97
+ this.branches.union =
98
+ this.branches.union?.or(this.branches.intersection) ??
99
+ this.branches.intersection;
100
+ this.branches.intersection = null;
100
101
  }
101
102
  this.root = undefined;
102
103
  }
@@ -117,17 +118,21 @@ export class DynamicState {
117
118
  reduceGroupOpen() {
118
119
  this.groups.push(this.branches);
119
120
  this.branches = {
120
- prefixes: []
121
+ prefixes: [],
122
+ leftBound: null,
123
+ union: null,
124
+ intersection: null
121
125
  };
122
126
  }
123
127
  previousOperator() {
124
128
  return (this.branches.leftBound?.comparator ??
125
129
  this.branches.prefixes.at(-1) ??
126
- (this.branches["&"] ? "&" : this.branches["|"] ? "|" : undefined));
130
+ (this.branches.intersection ? "&"
131
+ : this.branches.union ? "|"
132
+ : undefined));
127
133
  }
128
134
  shiftedByOne() {
129
135
  this.scanner.shift();
130
136
  return this;
131
137
  }
132
138
  }
133
- //# sourceMappingURL=dynamic.js.map
@@ -1,4 +1,4 @@
1
- import type { DateLiteral } from "@arktype/schema";
1
+ import type { LimitLiteral } from "@arktype/schema";
2
2
  export type StringifiablePrefixOperator = "keyof";
3
3
  export declare const minComparators: {
4
4
  readonly ">": true;
@@ -11,22 +11,21 @@ export declare const maxComparators: {
11
11
  };
12
12
  export type MaxComparator = keyof typeof maxComparators;
13
13
  export declare const comparators: {
14
+ ">": boolean;
15
+ ">=": boolean;
16
+ "<": boolean;
17
+ "<=": boolean;
14
18
  "==": boolean;
15
- "<": true;
16
- "<=": true;
17
- ">": true;
18
- ">=": true;
19
19
  };
20
20
  export type Comparator = keyof typeof comparators;
21
- export declare const invertedComparators: {
22
- readonly "<": ">";
23
- readonly ">": "<";
24
- readonly "<=": ">=";
25
- readonly ">=": "<=";
26
- readonly "==": "==";
21
+ export declare const invertedComparators: InvertedComparators;
22
+ export type InvertedComparators = {
23
+ "<": ">";
24
+ ">": "<";
25
+ "<=": ">=";
26
+ ">=": "<=";
27
+ "==": "==";
27
28
  };
28
- export type InvertedComparators = typeof invertedComparators;
29
- export type LimitLiteral = number | DateLiteral;
30
29
  export type OpenLeftBound = {
31
30
  limit: LimitLiteral;
32
31
  comparator: MinComparator;
@@ -38,19 +37,6 @@ export type writeUnclosedGroupMessage<missingChar extends string> = `Missing ${m
38
37
  export declare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends ">" | ">=">(min: min, comparator: comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
39
38
  export type writeOpenRangeMessage<min extends LimitLiteral, comparator extends MinComparator> = `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
40
39
  export type writeUnpairableComparatorMessage<comparator extends Comparator> = `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
41
- export declare const writeUnpairableComparatorMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=">(comparator: comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
42
- export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => `An expression may have at most one left bound (parsed ${openLimit}${{
43
- readonly "<": ">";
44
- readonly ">": "<";
45
- readonly "<=": ">=";
46
- readonly ">=": "<=";
47
- readonly "==": "==";
48
- }[openComparator]}, ${limit}${{
49
- readonly "<": ">";
50
- readonly ">": "<";
51
- readonly "<=": ">=";
52
- readonly ">=": "<=";
53
- readonly "==": "==";
54
- }[comparator]})`;
40
+ export declare const writeUnpairableComparatorMessage: <comparator extends ">" | "<" | ">=" | "<=" | "==">(comparator: comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
41
+ export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;
55
42
  export type writeMultipleLeftBoundsMessage<openLimit extends LimitLiteral, openComparator extends MinComparator, limit extends LimitLiteral, comparator extends MinComparator> = `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;
56
- //# sourceMappingURL=shared.d.ts.map
@@ -7,8 +7,10 @@ export const maxComparators = {
7
7
  "<=": true
8
8
  };
9
9
  export const comparators = {
10
- ...minComparators,
11
- ...maxComparators,
10
+ ">": true,
11
+ ">=": true,
12
+ "<": true,
13
+ "<=": true,
12
14
  "==": true
13
15
  };
14
16
  export const invertedComparators = {
@@ -23,4 +25,3 @@ export const writeUnclosedGroupMessage = (missingChar) => `Missing ${missingChar
23
25
  export const writeOpenRangeMessage = (min, comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
24
26
  export const writeUnpairableComparatorMessage = (comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
25
27
  export const writeMultipleLeftBoundsMessage = (openLimit, openComparator, limit, comparator) => `An expression may have at most one left bound (parsed ${openLimit}${invertedComparators[openComparator]}, ${limit}${invertedComparators[comparator]})`;
26
- //# sourceMappingURL=shared.js.map