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,18 +1,20 @@
1
- import { keywords } from "@arktype/schema";
2
- import { isKeyOf, throwParseError, tryParseNumber } from "@arktype/util";
3
- import { maxComparators, writeUnpairableComparatorMessage } from "../../reduce/shared.js";
1
+ import { internalKeywords, jsObjects, tsKeywords, writeUnboundableMessage } from "@arktype/schema";
2
+ import { isKeyOf, throwParseError } from "@arktype/util";
3
+ import { invertedComparators, maxComparators, writeUnpairableComparatorMessage } from "../../reduce/shared.js";
4
4
  import { extractDateLiteralSource, isDateLiteral } from "../operand/date.js";
5
5
  export const parseBound = (s, start) => {
6
6
  const comparator = shiftComparator(s, start);
7
- if (s.root.kind === "unit") {
7
+ if (s.root.hasKind("unit")) {
8
8
  if (typeof s.root.unit === "number") {
9
+ s.reduceLeftBound(s.root.unit, comparator);
9
10
  s.unsetRoot();
10
- return s.reduceLeftBound(s.root.unit, comparator);
11
+ return;
11
12
  }
12
13
  if (s.root.unit instanceof Date) {
13
- s.unsetRoot();
14
14
  const literal = `d'${s.root.description ?? s.root.unit.toISOString()}'`;
15
- return s.reduceLeftBound(literal, comparator);
15
+ s.unsetRoot();
16
+ s.reduceLeftBound(literal, comparator);
17
+ return;
16
18
  }
17
19
  }
18
20
  return parseRightBound(s, comparator);
@@ -26,49 +28,39 @@ export const comparatorStartChars = {
26
28
  ">": 1,
27
29
  "=": 1
28
30
  };
29
- const shiftComparator = (s, start) => s.scanner.lookaheadIs("=")
30
- ? `${start}${s.scanner.shift()}`
31
- : isKeyOf(start, oneCharComparators)
32
- ? start
31
+ const shiftComparator = (s, start) => s.scanner.lookaheadIs("=") ? `${start}${s.scanner.shift()}`
32
+ : isKeyOf(start, oneCharComparators) ? start
33
33
  : s.error(singleEqualsMessage);
34
- export const writeUnboundableMessage = (root) => `Bounded expression ${root} must be a number, string, Array, or Date`;
35
34
  export const writeIncompatibleRangeMessage = (l, r) => `Bound kinds ${l} and ${r} are incompatible`;
36
- export const writeLimitMismatchMessage = (root, limitValue) => `Limit '${limitValue}' cannot bound ${root}`;
37
- export const getBoundKinds = (comparator, limit, root) => {
38
- if (root.extends(keywords.number)) {
35
+ export const getBoundKinds = (comparator, limit, root, boundKind) => {
36
+ if (root.extends(tsKeywords.number)) {
39
37
  if (typeof limit !== "number") {
40
- return throwParseError(writeLimitMismatchMessage(root.toString(), limit));
38
+ return throwParseError(writeInvalidLimitMessage(comparator, limit, boundKind));
41
39
  }
42
- return comparator === "=="
43
- ? ["min", "max"]
44
- : comparator[0] === ">"
45
- ? ["min"]
46
- : ["max"];
40
+ return (comparator === "==" ? ["min", "max"]
41
+ : comparator[0] === ">" ? ["min"]
42
+ : ["max"]);
47
43
  }
48
- if (root.extends(keywords.string) || root.extends(keywords.Array)) {
44
+ if (root.extends(internalKeywords.lengthBoundable)) {
49
45
  if (typeof limit !== "number") {
50
- return throwParseError(writeLimitMismatchMessage(root.toString(), limit));
46
+ return throwParseError(writeInvalidLimitMessage(comparator, limit, boundKind));
51
47
  }
52
- return comparator === "=="
53
- ? ["minLength", "maxLength"]
54
- : comparator[0] === ">"
55
- ? ["minLength"]
56
- : ["maxLength"];
48
+ return (comparator === "==" ? ["minLength", "maxLength"]
49
+ : comparator[0] === ">" ? ["minLength"]
50
+ : ["maxLength"]);
57
51
  }
58
- if (root.extends(keywords.Date)) {
52
+ if (root.extends(jsObjects.Date)) {
59
53
  // allow either numeric or date limits
60
- return comparator === "=="
61
- ? ["after", "before"]
62
- : comparator[0] === ">"
63
- ? ["after"]
64
- : ["before"];
54
+ return (comparator === "==" ? ["after", "before"]
55
+ : comparator[0] === ">" ? ["after"]
56
+ : ["before"]);
65
57
  }
66
- return throwParseError(writeUnboundableMessage(root.toString()));
58
+ return throwParseError(writeUnboundableMessage(root.expression));
67
59
  };
68
- export const singleEqualsMessage = `= is not a valid comparator. Use == to check for equality`;
69
- const openLeftBoundToSchema = (leftBound) => ({
70
- limit: isDateLiteral(leftBound.limit)
71
- ? extractDateLiteralSource(leftBound.limit)
60
+ export const singleEqualsMessage = "= is not a valid comparator. Use == to check for equality";
61
+ const openLeftBoundToRoot = (leftBound) => ({
62
+ rule: isDateLiteral(leftBound.limit) ?
63
+ extractDateLiteralSource(leftBound.limit)
72
64
  : leftBound.limit,
73
65
  exclusive: leftBound.comparator.length === 1
74
66
  });
@@ -77,30 +69,27 @@ export const parseRightBound = (s, comparator) => {
77
69
  const previousRoot = s.unsetRoot();
78
70
  const previousScannerIndex = s.scanner.location;
79
71
  s.parseOperand();
72
+ const limitNode = s.unsetRoot();
80
73
  // after parsing the next operand, use the locations to get the
81
74
  // token from which it was parsed
82
75
  const limitToken = s.scanner.sliceChars(previousScannerIndex, s.scanner.location);
83
- s.setRoot(previousRoot);
84
- const limit = tryParseNumber(limitToken) ??
85
- (isDateLiteral(limitToken)
86
- ? extractDateLiteralSource(limitToken)
87
- : s.error(writeInvalidLimitMessage(comparator, limitToken, "right")));
76
+ s.root = previousRoot;
77
+ if (!limitNode.hasKind("unit") ||
78
+ (typeof limitNode.unit !== "number" && !(limitNode.unit instanceof Date)))
79
+ return s.error(writeInvalidLimitMessage(comparator, limitToken, "right"));
80
+ const limit = limitNode.unit;
88
81
  // apply the newly-parsed right bound
89
82
  const exclusive = comparator.length === 1;
90
83
  // if the comparator is ==, both the min and max of that pair will be applied
91
- for (const kind of getBoundKinds(comparator, limit, previousRoot)) {
92
- s.constrainRoot(kind, { limit, exclusive });
93
- }
94
- if (!s.branches.leftBound) {
84
+ for (const kind of getBoundKinds(comparator, typeof limit === "number" ? limit : limitToken, previousRoot, "right"))
85
+ s.constrainRoot(kind, { rule: limit, exclusive });
86
+ if (!s.branches.leftBound)
95
87
  return;
96
- }
97
88
  // if there's an open left bound, perform additional validation and apply it
98
- if (!isKeyOf(comparator, maxComparators)) {
89
+ if (!isKeyOf(comparator, maxComparators))
99
90
  return s.error(writeUnpairableComparatorMessage(comparator));
100
- }
101
- const lowerBoundKind = getBoundKinds(s.branches.leftBound.comparator, s.branches.leftBound.limit, previousRoot);
102
- s.constrainRoot(lowerBoundKind[0], openLeftBoundToSchema(s.branches.leftBound));
103
- delete s.branches.leftBound;
91
+ const lowerBoundKind = getBoundKinds(s.branches.leftBound.comparator, s.branches.leftBound.limit, previousRoot, "left");
92
+ s.constrainRoot(lowerBoundKind[0], openLeftBoundToRoot(s.branches.leftBound));
93
+ s.branches.leftBound = null;
104
94
  };
105
- export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
106
- //# sourceMappingURL=bounds.js.map
95
+ export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${boundKind === "left" ? invertedComparators[comparator] : comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was ${limit})`;
@@ -1,9 +1,7 @@
1
- import { type NumberLiteral } from "@arktype/util";
2
1
  import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";
3
2
  import type { StaticState, state } from "../../reduce/static.js";
4
3
  import type { Scanner } from "../scanner.js";
5
4
  export declare const parseDivisor: (s: DynamicStateWithRoot) => void;
6
- export type parseDivisor<s extends StaticState, unscanned extends string> = Scanner.shiftUntilNextTerminator<Scanner.skipWhitespace<unscanned>> extends Scanner.shiftResult<infer scanned, infer nextUnscanned> ? scanned extends NumberLiteral<infer divisor> ? divisor extends 0 ? state.error<writeInvalidDivisorMessage<0>> : state.setRoot<s, [s["root"], "%", scanned], nextUnscanned> : state.error<writeInvalidDivisorMessage<scanned>> : never;
5
+ export type parseDivisor<s extends StaticState, unscanned extends string> = Scanner.shiftUntilNextTerminator<Scanner.skipWhitespace<unscanned>> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? scanned extends `${infer divisor extends number}` ? divisor extends 0 ? state.error<writeInvalidDivisorMessage<0>> : state.setRoot<s, [s["root"], "%", divisor], nextUnscanned> : state.error<writeInvalidDivisorMessage<scanned>> : never;
7
6
  export declare const writeInvalidDivisorMessage: <divisor extends string | number>(divisor: divisor) => `% operator must be followed by a non-zero integer literal (was ${divisor})`;
8
7
  export type writeInvalidDivisorMessage<divisor extends string | number> = `% operator must be followed by a non-zero integer literal (was ${divisor})`;
9
- //# sourceMappingURL=divisor.d.ts.map
@@ -4,10 +4,8 @@ export const parseDivisor = (s) => {
4
4
  const divisor = tryParseInteger(divisorToken, {
5
5
  errorOnFail: writeInvalidDivisorMessage(divisorToken)
6
6
  });
7
- if (divisor === 0) {
7
+ if (divisor === 0)
8
8
  s.error(writeInvalidDivisorMessage(0));
9
- }
10
9
  s.root = s.root.constrain("divisor", divisor);
11
10
  };
12
11
  export const writeInvalidDivisorMessage = (divisor) => `% operator must be followed by a non-zero integer literal (was ${divisor})`;
13
- //# sourceMappingURL=divisor.js.map
@@ -1,5 +1,5 @@
1
1
  import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";
2
- import type { state, StaticState } from "../../reduce/static.js";
2
+ import type { StaticState, state } from "../../reduce/static.js";
3
3
  import { Scanner } from "../scanner.js";
4
4
  import { parseBound, type ComparatorStartChar } from "./bounds.js";
5
5
  import { parseDivisor } from "./divisor.js";
@@ -10,4 +10,3 @@ export type writeUnexpectedCharacterMessage<char extends string, shouldBe extend
10
10
  export declare const incompleteArrayTokenMessage = "Missing expected ']'";
11
11
  type incompleteArrayTokenMessage = typeof incompleteArrayTokenMessage;
12
12
  export {};
13
- //# sourceMappingURL=operator.d.ts.map
@@ -4,26 +4,19 @@ import { comparatorStartChars, parseBound } from "./bounds.js";
4
4
  import { parseDivisor } from "./divisor.js";
5
5
  export const parseOperator = (s) => {
6
6
  const lookahead = s.scanner.shift();
7
- return lookahead === ""
8
- ? s.finalize("")
9
- : lookahead === "["
10
- ? s.scanner.shift() === "]"
11
- ? s.setRoot(s.root.array())
7
+ return (lookahead === "" ? s.finalize("")
8
+ : lookahead === "[" ?
9
+ s.scanner.shift() === "]" ?
10
+ s.setRoot(s.root.array())
12
11
  : s.error(incompleteArrayTokenMessage)
13
- : lookahead === "|" || lookahead === "&"
14
- ? s.pushRootToBranch(lookahead)
15
- : lookahead === ")"
16
- ? s.finalizeGroup()
17
- : Scanner.lookaheadIsFinalizing(lookahead, s.scanner.unscanned)
18
- ? s.finalize(lookahead)
19
- : isKeyOf(lookahead, comparatorStartChars)
20
- ? parseBound(s, lookahead)
21
- : lookahead === "%"
22
- ? parseDivisor(s)
23
- : lookahead === " "
24
- ? parseOperator(s)
25
- : s.error(writeUnexpectedCharacterMessage(lookahead));
12
+ : lookahead === "|" || lookahead === "&" ? s.pushRootToBranch(lookahead)
13
+ : lookahead === ")" ? s.finalizeGroup()
14
+ : Scanner.lookaheadIsFinalizing(lookahead, s.scanner.unscanned) ?
15
+ s.finalize(lookahead)
16
+ : isKeyOf(lookahead, comparatorStartChars) ? parseBound(s, lookahead)
17
+ : lookahead === "%" ? parseDivisor(s)
18
+ : lookahead === " " ? parseOperator(s)
19
+ : s.error(writeUnexpectedCharacterMessage(lookahead)));
26
20
  };
27
21
  export const writeUnexpectedCharacterMessage = (char, shouldBe = "") => `'${char}' is not allowed here${shouldBe && ` (should be ${shouldBe})`}`;
28
22
  export const incompleteArrayTokenMessage = `Missing expected ']'`;
29
- //# sourceMappingURL=operator.js.map
@@ -54,10 +54,11 @@ export declare namespace Scanner {
54
54
  const whiteSpaceTokens: {
55
55
  readonly " ": true;
56
56
  readonly "\n": true;
57
+ readonly "\t": true;
57
58
  };
58
59
  type WhiteSpaceToken = keyof typeof whiteSpaceTokens;
59
60
  const lookaheadIsFinalizing: (lookahead: string, unscanned: string) => lookahead is ">" | ",";
60
- type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends "" | `${TerminatingChar}${string}` ? true : false : lookahead extends "," ? true : false;
61
+ type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends ("" | `${TerminatingChar}${string}`) ? true : false : lookahead extends "," ? true : false;
61
62
  type shift<lookahead extends string, unscanned extends string> = `${lookahead}${unscanned}`;
62
63
  type shiftUntil<unscanned extends string, terminator extends string, scanned extends string = ""> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends terminator ? scanned extends `${infer base}${EscapeToken}` ? shiftUntil<nextUnscanned, terminator, `${base}${lookahead}`> : [scanned, unscanned] : shiftUntil<nextUnscanned, terminator, `${scanned}${lookahead}`> : [scanned, ""];
63
64
  type shiftUntilNot<unscanned extends string, nonTerminator extends string, scanned extends string = ""> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends nonTerminator ? shiftUntilNot<nextUnscanned, nonTerminator, `${scanned}${lookahead}`> : [scanned, unscanned] : [scanned, ""];
@@ -68,4 +69,3 @@ export declare namespace Scanner {
68
69
  unscanned
69
70
  ];
70
71
  }
71
- //# sourceMappingURL=scanner.d.ts.map
@@ -20,12 +20,10 @@ export class Scanner {
20
20
  let shifted = "";
21
21
  while (this.lookahead) {
22
22
  if (condition(this, shifted)) {
23
- if (shifted[shifted.length - 1] === Scanner.escapeToken) {
23
+ if (shifted[shifted.length - 1] === Scanner.escapeToken)
24
24
  shifted = shifted.slice(0, -1);
25
- }
26
- else {
25
+ else
27
26
  break;
28
- }
29
27
  }
30
28
  shifted += this.shift();
31
29
  }
@@ -83,17 +81,17 @@ export class Scanner {
83
81
  Scanner.escapeToken = "\\";
84
82
  Scanner.whiteSpaceTokens = {
85
83
  " ": true,
86
- "\n": true
84
+ "\n": true,
85
+ "\t": true
87
86
  };
88
- Scanner.lookaheadIsFinalizing = (lookahead, unscanned) => lookahead === ">"
89
- ? unscanned[0] === "="
90
- ? // >== would only occur in an expression like Array<number>==5
91
- // otherwise, >= would only occur as part of a bound like number>=5
92
- unscanned[1] === "="
93
- : // if > is the end of a generic instantiation, the next token will be an operator or the end of the string
94
- unscanned.trimStart() === "" ||
95
- isKeyOf(unscanned.trimStart()[0], Scanner.terminatingChars)
96
- : // if the lookahead is a finalizing token but not >, it's unambiguously a finalizer (currently just ",")
97
- lookahead === ",";
87
+ Scanner.lookaheadIsFinalizing = (lookahead, unscanned) => lookahead === ">" ?
88
+ unscanned[0] === "=" ?
89
+ // >== would only occur in an expression like Array<number>==5
90
+ // otherwise, >= would only occur as part of a bound like number>=5
91
+ unscanned[1] === "="
92
+ // if > is the end of a generic instantiation, the next token will be an operator or the end of the string
93
+ : unscanned.trimStart() === "" ||
94
+ isKeyOf(unscanned.trimStart()[0], Scanner.terminatingChars)
95
+ // if the lookahead is a finalizing token but not >, it's unambiguously a finalizer (currently just ",")
96
+ : lookahead === ",";
98
97
  })(Scanner || (Scanner = {}));
99
- //# sourceMappingURL=scanner.js.map
@@ -1,19 +1,22 @@
1
- import type { TypeNode } from "@arktype/schema";
1
+ import type { BaseRoot } from "@arktype/schema";
2
2
  import { type ErrorMessage } from "@arktype/util";
3
- import type { inferAstRoot } from "../semantic/semantic.js";
3
+ import type { inferAstRoot } from "../semantic/infer.js";
4
4
  import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.js";
5
5
  import type { StringifiablePrefixOperator } from "./reduce/shared.js";
6
6
  import type { StaticState, state } from "./reduce/static.js";
7
7
  import type { parseOperand } from "./shift/operand/operand.js";
8
- import { writeUnexpectedCharacterMessage, type parseOperator } from "./shift/operator/operator.js";
8
+ import { type parseOperator, writeUnexpectedCharacterMessage } from "./shift/operator/operator.js";
9
9
  /**
10
10
  * Try to parse the definition from right to left using the most common syntax.
11
11
  * This can be much more efficient for simple definitions.
12
12
  */
13
- export type parseString<def extends string, $, args> = def extends keyof $ ? def : def extends `${infer child}[]` ? child extends keyof $ ? [child, "[]"] : fullStringParse<state.initialize<def>, $, args> : fullStringParse<state.initialize<def>, $, args>;
13
+ export type parseString<def extends string, $, args> = def extends keyof $ ? def : def extends `${infer child}[]` ? child extends keyof $ ? [
14
+ child,
15
+ "[]"
16
+ ] : fullStringParse<state.initialize<def>, $, args> : fullStringParse<state.initialize<def>, $, args>;
14
17
  export type inferString<def extends string, $, args> = inferAstRoot<parseString<def, $, args>, $, args>;
15
18
  export type BaseCompletions<$, args, otherSuggestions extends string = never> = (keyof $ & string) | (keyof args & string) | StringifiablePrefixOperator | otherSuggestions;
16
- export declare const fullStringParse: (s: DynamicState) => TypeNode;
19
+ export declare const fullStringParse: (s: DynamicState) => BaseRoot;
17
20
  type fullStringParse<s extends StaticState, $, args> = extractFinalizedResult<parseUntilFinalizer<s, $, args>>;
18
21
  export declare const parseUntilFinalizer: (s: DynamicState) => DynamicStateWithRoot;
19
22
  export type parseUntilFinalizer<s extends StaticState, $, args> = s["finalizer"] extends undefined ? parseUntilFinalizer<next<s, $, args>, $, args> : s;
@@ -21,4 +24,3 @@ declare const next: (s: DynamicState) => void;
21
24
  type next<s extends StaticState, $, args> = s["root"] extends undefined ? parseOperand<s, $, args> : parseOperator<s, $, args>;
22
25
  export type extractFinalizedResult<s extends StaticState> = s["finalizer"] extends ErrorMessage ? s["finalizer"] : s["finalizer"] extends "" ? s["root"] : state.error<writeUnexpectedCharacterMessage<`${s["finalizer"]}`>>;
23
26
  export {};
24
- //# sourceMappingURL=string.d.ts.map
@@ -14,10 +14,8 @@ export const fullStringParse = (s) => {
14
14
  return result;
15
15
  };
16
16
  export const parseUntilFinalizer = (s) => {
17
- while (s.finalizer === undefined) {
17
+ while (s.finalizer === undefined)
18
18
  next(s);
19
- }
20
19
  return s;
21
20
  };
22
21
  const next = (s) => s.hasRoot() ? s.parseOperator() : s.parseOperand();
23
- //# sourceMappingURL=string.js.map
@@ -1,58 +1,119 @@
1
- import { type BaseMeta, type Morph, type Out, type Predicate, type TypeNode, type extractIn, type extractOut, type inferMorphOut, type inferNarrow } from "@arktype/schema";
2
- import { type Constructor, type Domain, type List, type conform, type evaluate, type isAny } from "@arktype/util";
1
+ import { type BaseMeta, type BaseRoot, type Morph, type Out, type Predicate, type distillConstrainableIn, type distillConstrainableOut, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
2
+ import { type Constructor, type Domain, type ErrorMessage, type array, type conform, type show } from "@arktype/util";
3
3
  import type { ParseContext } from "../scope.js";
4
4
  import type { inferDefinition, validateDefinition } from "./definition.js";
5
- import type { inferIntersection } from "./semantic/intersections.js";
6
- import type { InfixOperator, PostfixExpression } from "./semantic/semantic.js";
7
- import { parseEntry, type EntryParseResult, type validateObjectValue } from "./shared.js";
5
+ import type { InfixOperator, PostfixExpression } from "./semantic/infer.js";
8
6
  import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.js";
9
7
  import type { BaseCompletions } from "./string/string.js";
10
- export declare const parseTuple: (def: List, ctx: ParseContext) => TypeNode;
11
- export declare const parseTupleLiteral: (def: List, ctx: ParseContext) => TypeNode;
12
- export declare const maybeParseTupleExpression: (def: List, ctx: ParseContext) => TypeNode | undefined;
8
+ export declare const parseTuple: (def: array, ctx: ParseContext) => BaseRoot;
9
+ export declare const parseTupleLiteral: (def: array, ctx: ParseContext) => BaseRoot;
13
10
  type InfixExpression = readonly [unknown, InfixOperator, ...unknown[]];
14
- export type validateTuple<def extends List, $, args> = def extends IndexZeroExpression ? validatePrefixExpression<def, $, args> : def extends PostfixExpression ? validatePostfixExpression<def, $, args> : def extends InfixExpression ? validateInfixExpression<def, $, args> : def extends readonly ["", ...unknown[]] | readonly [unknown, "", ...unknown[]] ? readonly [
15
- def[0] extends "" ? BaseCompletions<$, args, IndexZeroOperator> : def[0],
16
- def[1] extends "" ? BaseCompletions<$, args, IndexOneOperator> : def[1]
11
+ export type validateTuple<def extends array, $, args> = def extends IndexZeroExpression ? validatePrefixExpression<def, $, args> : def extends PostfixExpression ? validatePostfixExpression<def, $, args> : def extends InfixExpression ? validateInfixExpression<def, $, args> : def extends (readonly ["", ...unknown[]] | readonly [unknown, "", ...unknown[]]) ? readonly [
12
+ def[0] extends "" ? BaseCompletions<$, args, IndexZeroOperator | "..."> : def[0],
13
+ def[1] extends "" ? BaseCompletions<$, args, IndexOneOperator | "..." | "?"> : def[1]
17
14
  ] : validateTupleLiteral<def, $, args>;
18
- export type validateTupleLiteral<def extends List, $, args, result extends unknown[] = []> = def extends readonly [infer head, ...infer tail] ? validateTupleLiteral<tail, $, args, [
19
- ...result,
20
- validateTupleElement<head, tail, $, args>
21
- ]> : result;
22
- type validateTupleElement<head, tail, $, args> = head extends variadicExpression<infer operand> ? validateDefinition<operand, $, args> extends infer syntacticResult ? syntacticResult extends operand ? semanticallyValidateRestElement<operand, $, args> extends infer semanticResult ? semanticResult extends operand ? tail extends [] ? head : prematureRestMessage : semanticResult : never : syntacticResult : never : validateObjectValue<head, $, args>;
23
- type semanticallyValidateRestElement<operand, $, args> = inferDefinition<operand, $, args> extends infer result ? result extends never ? writeNonArrayRestMessage<operand> : isAny<result> extends true ? writeNonArrayRestMessage<operand> : result extends readonly unknown[] ? operand : writeNonArrayRestMessage<operand> : never;
24
- export declare const writeNonArrayRestMessage: <operand>(operand: operand) => `Rest element ${operand extends string ? `'${operand}'` : ""} must be an array`;
25
- type writeNonArrayRestMessage<operand> = `Rest element ${operand extends string ? `'${operand}'` : ""} must be an array`;
26
- export declare const prematureRestMessage = "Rest elements are only allowed at the end of a tuple";
27
- type prematureRestMessage = typeof prematureRestMessage;
28
- type inferTupleLiteral<def extends List, $, args, result extends unknown[] = []> = def extends readonly [infer head, ...infer tail] ? parseEntry<result["length"], head extends variadicExpression<infer operand> ? operand : head> extends infer entryParseResult extends EntryParseResult ? inferDefinition<entryParseResult["innerValue"], $, args> extends infer element ? head extends variadicExpression ? element extends readonly unknown[] ? inferTupleLiteral<tail, $, args, [...result, ...element]> : never : inferTupleLiteral<tail, $, args, entryParseResult["kind"] extends "optional" ? [...result, element?] : [...result, element]> : never : never : result;
29
- type variadicExpression<operandDef = unknown> = variadicStringExpression<operandDef & string> | variadicTupleExpression<operandDef>;
30
- type variadicStringExpression<operandDef extends string = string> = `...${operandDef}`;
31
- type variadicTupleExpression<operandDef = unknown> = readonly [
32
- "...",
33
- operandDef
34
- ];
35
- export type inferTuple<def extends List, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
36
- export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferNarrow<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def extends readonly ["===", ...infer values] ? values[number] : def extends readonly [
37
- "instanceof",
38
- ...infer constructors extends Constructor[]
39
- ] ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
15
+ export type validateTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? Readonly<s["validated"]> : never;
16
+ type inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? s["inferred"] : never;
17
+ type SequenceParseState = {
18
+ unscanned: array;
19
+ inferred: array;
20
+ validated: array;
21
+ };
22
+ type parseSequence<def extends array, $, args> = parseNextElement<{
23
+ unscanned: def;
24
+ inferred: [];
25
+ validated: [];
26
+ }, $, args>;
27
+ type PreparsedElement = {
28
+ head: unknown;
29
+ tail: array;
30
+ optional: boolean;
31
+ spread: boolean;
32
+ };
33
+ declare namespace PreparsedElement {
34
+ type from<result extends PreparsedElement> = result;
35
+ }
36
+ type preparseNextElement<s extends SequenceParseState> = s["unscanned"] extends readonly ["...", infer head, ...infer tail] ? tail extends readonly ["?", ...infer postOptionalTail] ? PreparsedElement.from<{
37
+ head: head;
38
+ tail: postOptionalTail;
39
+ optional: true;
40
+ spread: true;
41
+ }> : PreparsedElement.from<{
42
+ head: head;
43
+ tail: tail;
44
+ optional: false;
45
+ spread: true;
46
+ }> : s["unscanned"] extends readonly [infer head, "?", ...infer tail] ? PreparsedElement.from<{
47
+ head: head;
48
+ tail: tail;
49
+ optional: true;
50
+ spread: false;
51
+ }> : s["unscanned"] extends readonly [infer head, ...infer tail] ? PreparsedElement.from<{
52
+ head: head;
53
+ tail: tail;
54
+ optional: false;
55
+ spread: false;
56
+ }> : null;
57
+ type parseNextElement<s extends SequenceParseState, $, args> = preparseNextElement<s> extends infer next extends PreparsedElement ? parseNextElement<{
58
+ unscanned: next["tail"];
59
+ inferred: next["spread"] extends true ? [
60
+ ...s["inferred"],
61
+ ...conform<inferDefinition<next["head"], $, args>, array>
62
+ ] : next["optional"] extends true ? [
63
+ ...s["inferred"],
64
+ inferDefinition<next["head"], $, args>?
65
+ ] : [...s["inferred"], inferDefinition<next["head"], $, args>];
66
+ validated: [
67
+ ...s["validated"],
68
+ ...(next["spread"] extends true ? [
69
+ inferDefinition<next["head"], $, args> extends (infer spreadOperand extends array) ? [
70
+ number,
71
+ number
72
+ ] extends ([
73
+ s["inferred"]["length"],
74
+ spreadOperand["length"]
75
+ ]) ? ErrorMessage<multipleVariadicMessage> : "..." : ErrorMessage<writeNonArraySpreadMessage<next["head"]>>
76
+ ] : []),
77
+ [
78
+ next["optional"] | next["spread"],
79
+ "?"
80
+ ] extends ([
81
+ false,
82
+ s["validated"][number]
83
+ ]) ? ErrorMessage<requiredPostOptionalMessage> : validateDefinition<next["head"], $, args>,
84
+ ...(next["optional"] extends true ? [
85
+ next["spread"] extends true ? ErrorMessage<spreadOptionalMessage> : number extends s["inferred"]["length"] ? ErrorMessage<optionalPostVariadicMessage> : "?"
86
+ ] : [])
87
+ ];
88
+ }, $, args> : s;
89
+ export declare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
90
+ type writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
91
+ export declare const multipleVariadicMesage = "A tuple may have at most one variadic element";
92
+ type multipleVariadicMessage = typeof multipleVariadicMesage;
93
+ export declare const requiredPostOptionalMessage = "A required element may not follow an optional element";
94
+ type requiredPostOptionalMessage = typeof requiredPostOptionalMessage;
95
+ export declare const optionalPostVariadicMessage = "An optional element may not follow a variadic element";
96
+ type optionalPostVariadicMessage = typeof optionalPostVariadicMessage;
97
+ export declare const spreadOptionalMessage = "A spread element cannot be optional";
98
+ type spreadOptionalMessage = typeof optionalPostVariadicMessage;
99
+ export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
100
+ export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferNarrow<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
40
101
  export type validatePrefixExpression<def extends IndexZeroExpression, $, args> = def["length"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>] : def[0] extends "keyof" ? readonly [def[0], validateDefinition<def[1], $, args>] : def[0] extends "===" ? readonly [def[0], ...unknown[]] : def[0] extends "instanceof" ? readonly [def[0], ...Constructor[]] : never;
41
102
  export type validatePostfixExpression<def extends PostfixExpression, $, args> = conform<def, readonly [validateDefinition<def[0], $, args>, "[]"]>;
42
103
  export type validateInfixExpression<def extends InfixExpression, $, args> = def["length"] extends 2 ? readonly [def[0], writeMissingRightOperandMessage<def[1]>] : readonly [
43
104
  validateDefinition<def[0], $, args>,
44
105
  def[1],
45
- def[1] extends "|" ? validateDefinition<def[2], $, args> : def[1] extends "&" ? validateDefinition<def[2], $, args> : def[1] extends ":" ? Predicate<extractIn<inferDefinition<def[0], $, args>>> : def[1] extends "=>" ? Morph<extractOut<inferDefinition<def[0], $, args>>, unknown> : def[1] extends "@" ? BaseMeta | string : validateDefinition<def[2], $, args>
106
+ def[1] extends "|" ? validateDefinition<def[2], $, args> : def[1] extends "&" ? validateDefinition<def[2], $, args> : def[1] extends ":" ? Predicate<distillConstrainableIn<inferDefinition<def[0], $, args>>> : def[1] extends "=>" ? Morph<distillConstrainableOut<inferDefinition<def[0], $, args>>, unknown> : def[1] extends "@" ? BaseMeta | string : validateDefinition<def[2], $, args>
46
107
  ];
47
108
  export type UnparsedTupleExpressionInput = {
48
109
  instanceof: Constructor;
49
110
  "===": unknown;
50
111
  };
51
- export type UnparsedTupleOperator = evaluate<keyof UnparsedTupleExpressionInput>;
112
+ export type UnparsedTupleOperator = show<keyof UnparsedTupleExpressionInput>;
52
113
  export declare const parseKeyOfTuple: PrefixParser<"keyof">;
53
- export type inferKeyOfExpression<operandDef, $, args> = evaluate<keyof inferDefinition<operandDef, $, args>>;
54
- export type PostfixParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: ParseContext) => TypeNode;
55
- export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: ParseContext) => TypeNode;
114
+ export type inferKeyOfExpression<operandDef, $, args> = show<keyof inferDefinition<operandDef, $, args>>;
115
+ export type PostfixParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: ParseContext) => BaseRoot;
116
+ export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: ParseContext) => BaseRoot;
56
117
  export type TupleExpression = IndexZeroExpression | IndexOneExpression;
57
118
  export type TupleExpressionOperator = IndexZeroOperator | IndexOneOperator;
58
119
  export type IndexOneOperator = TuplePostfixOperator | TupleInfixOperator;
@@ -60,12 +121,10 @@ export type TuplePostfixOperator = "[]";
60
121
  export type TupleInfixOperator = "&" | "|" | "=>" | ":" | "@";
61
122
  export type IndexOneExpression<token extends IndexOneOperator = IndexOneOperator> = readonly [unknown, token, ...unknown[]];
62
123
  export declare const parseMorphTuple: PostfixParser<"=>">;
63
- export declare const writeMalformedFunctionalExpressionMessage: (operator: FunctionalTupleOperator, value: unknown) => string;
64
- export type parseMorph<inDef, morph, $, args> = morph extends Morph ? (In: extractIn<inferDefinition<inDef, $, args>>) => Out<inferMorphOut<ReturnType<morph>>> : never;
124
+ export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => string;
125
+ export type parseMorph<inDef, morph, $, args> = morph extends Morph ? (In: distillConstrainableIn<inferDefinition<inDef, $, args>>) => Out<inferMorphOut<morph>> : never;
65
126
  export declare const parseNarrowTuple: PostfixParser<":">;
66
- export type FunctionalTupleOperator = ":" | "=>";
67
127
  export type IndexZeroOperator = "keyof" | "instanceof" | "===";
68
128
  export type IndexZeroExpression<token extends IndexZeroOperator = IndexZeroOperator> = readonly [token, ...unknown[]];
69
- export declare const writeInvalidConstructorMessage: <actual extends "Array" | "Date" | "Error" | "Function" | "Map" | "RegExp" | "Set" | "String" | "Number" | "Boolean" | "WeakMap" | "WeakSet" | "Promise" | Domain>(actual: actual) => string;
129
+ export declare const writeInvalidConstructorMessage: <actual extends Domain | keyof import("@arktype/util").builtinConstructors>(actual: actual) => string;
70
130
  export {};
71
- //# sourceMappingURL=tuple.d.ts.map