arktype 2.0.0-dev.7 → 2.0.0-dev.9

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 (414) hide show
  1. package/__tests__/array.test.ts +23 -25
  2. package/__tests__/config.test.ts +19 -8
  3. package/__tests__/examples.test.ts +3 -3
  4. package/__tests__/imports.test.ts +18 -12
  5. package/__tests__/instanceof.test.ts +7 -7
  6. package/__tests__/intersection.test.ts +2 -2
  7. package/__tests__/keyTraversal.test.ts +15 -15
  8. package/__tests__/keywords.test.ts +50 -37
  9. package/__tests__/literal.test.ts +30 -14
  10. package/__tests__/match.bench.ts +6 -6
  11. package/__tests__/narrow.test.ts +18 -24
  12. package/__tests__/objectLiteral.test.ts +134 -11
  13. package/__tests__/operator.bench.ts +4 -4
  14. package/__tests__/{morph.test.ts → pipe.test.ts} +136 -75
  15. package/__tests__/scope.test.ts +202 -15
  16. package/__tests__/traverse.test.ts +45 -36
  17. package/__tests__/type.test.ts +8 -10
  18. package/ark.ts +14 -11
  19. package/generic.ts +8 -6
  20. package/match.ts +59 -70
  21. package/out/ark.d.ts +5 -5
  22. package/out/ark.js +4 -5
  23. package/out/ark.js.map +1 -1
  24. package/out/generic.d.ts +0 -1
  25. package/out/generic.js +8 -7
  26. package/out/generic.js.map +1 -1
  27. package/out/main.d.ts +0 -1
  28. package/out/main.js +0 -1
  29. package/out/match.d.ts +0 -1
  30. package/out/match.js +50 -57
  31. package/out/match.js.map +1 -1
  32. package/out/module.d.ts +0 -1
  33. package/out/module.js +0 -1
  34. package/out/parser/definition.d.ts +1 -2
  35. package/out/parser/definition.js +0 -1
  36. package/out/parser/generic.d.ts +5 -6
  37. package/out/parser/generic.js +4 -6
  38. package/out/parser/generic.js.map +1 -1
  39. package/out/parser/objectLiteral.d.ts +1 -2
  40. package/out/parser/objectLiteral.js +17 -11
  41. package/out/parser/objectLiteral.js.map +1 -1
  42. package/out/parser/semantic/bounds.d.ts +1 -2
  43. package/out/parser/semantic/bounds.js +0 -1
  44. package/out/parser/semantic/divisor.d.ts +0 -1
  45. package/out/parser/semantic/divisor.js +0 -2
  46. package/out/parser/semantic/infer.d.ts +0 -1
  47. package/out/parser/semantic/infer.js +0 -2
  48. package/out/parser/semantic/utils.d.ts +0 -1
  49. package/out/parser/semantic/utils.js +0 -2
  50. package/out/parser/semantic/validate.d.ts +4 -5
  51. package/out/parser/semantic/validate.js +0 -1
  52. package/out/parser/semantic/validate.js.map +1 -1
  53. package/out/parser/string/reduce/dynamic.d.ts +0 -1
  54. package/out/parser/string/reduce/dynamic.js +4 -9
  55. package/out/parser/string/reduce/dynamic.js.map +1 -1
  56. package/out/parser/string/reduce/shared.d.ts +5 -18
  57. package/out/parser/string/reduce/shared.js +0 -1
  58. package/out/parser/string/reduce/static.d.ts +0 -1
  59. package/out/parser/string/reduce/static.js +0 -2
  60. package/out/parser/string/shift/operand/date.d.ts +2 -3
  61. package/out/parser/string/shift/operand/date.js +2 -5
  62. package/out/parser/string/shift/operand/date.js.map +1 -1
  63. package/out/parser/string/shift/operand/enclosed.d.ts +2 -17
  64. package/out/parser/string/shift/operand/enclosed.js +6 -9
  65. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  66. package/out/parser/string/shift/operand/genericArgs.d.ts +5 -6
  67. package/out/parser/string/shift/operand/genericArgs.js +4 -6
  68. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  69. package/out/parser/string/shift/operand/operand.d.ts +0 -1
  70. package/out/parser/string/shift/operand/operand.js +0 -1
  71. package/out/parser/string/shift/operand/unenclosed.d.ts +6 -7
  72. package/out/parser/string/shift/operand/unenclosed.js +6 -13
  73. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  74. package/out/parser/string/shift/operator/bounds.d.ts +1 -8
  75. package/out/parser/string/shift/operator/bounds.js +4 -9
  76. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  77. package/out/parser/string/shift/operator/divisor.d.ts +1 -2
  78. package/out/parser/string/shift/operator/divisor.js +1 -3
  79. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  80. package/out/parser/string/shift/operator/operator.d.ts +1 -2
  81. package/out/parser/string/shift/operator/operator.js +0 -1
  82. package/out/parser/string/shift/scanner.d.ts +0 -1
  83. package/out/parser/string/shift/scanner.js +2 -5
  84. package/out/parser/string/shift/scanner.js.map +1 -1
  85. package/out/parser/string/string.d.ts +0 -1
  86. package/out/parser/string/string.js +1 -3
  87. package/out/parser/string/string.js.map +1 -1
  88. package/out/parser/tuple.d.ts +1 -2
  89. package/out/parser/tuple.js +12 -16
  90. package/out/parser/tuple.js.map +1 -1
  91. package/out/scope.d.ts +12 -12
  92. package/out/scope.js +16 -38
  93. package/out/scope.js.map +1 -1
  94. package/out/type.d.ts +38 -19
  95. package/out/type.js +32 -2
  96. package/out/type.js.map +1 -1
  97. package/package.json +6 -4
  98. package/parser/generic.ts +13 -14
  99. package/parser/objectLiteral.ts +25 -11
  100. package/parser/semantic/validate.ts +2 -3
  101. package/parser/string/reduce/dynamic.ts +7 -10
  102. package/parser/string/shift/operand/date.ts +3 -6
  103. package/parser/string/shift/operand/enclosed.ts +8 -8
  104. package/parser/string/shift/operand/genericArgs.ts +8 -8
  105. package/parser/string/shift/operand/unenclosed.ts +15 -25
  106. package/parser/string/shift/operator/bounds.ts +7 -9
  107. package/parser/string/shift/operator/divisor.ts +2 -3
  108. package/parser/string/shift/scanner.ts +2 -4
  109. package/parser/string/string.ts +2 -3
  110. package/parser/tuple.ts +15 -16
  111. package/scope.ts +39 -57
  112. package/type.ts +151 -35
  113. package/__tests__/cyclic.test.ts +0 -148
  114. package/out/ark.d.ts.map +0 -1
  115. package/out/base.d.ts +0 -205
  116. package/out/base.d.ts.map +0 -1
  117. package/out/base.js +0 -320
  118. package/out/base.js.map +0 -1
  119. package/out/builtins/builtins.d.ts +0 -23
  120. package/out/builtins/builtins.d.ts.map +0 -1
  121. package/out/builtins/builtins.js +0 -15
  122. package/out/builtins/builtins.js.map +0 -1
  123. package/out/builtins/jsObjects.d.ts +0 -19
  124. package/out/builtins/jsObjects.d.ts.map +0 -1
  125. package/out/builtins/jsObjects.js +0 -18
  126. package/out/builtins/jsObjects.js.map +0 -1
  127. package/out/builtins/parsing.d.ts +0 -16
  128. package/out/builtins/parsing.d.ts.map +0 -1
  129. package/out/builtins/parsing.js +0 -62
  130. package/out/builtins/parsing.js.map +0 -1
  131. package/out/builtins/tsGenerics.d.ts +0 -2
  132. package/out/builtins/tsGenerics.d.ts.map +0 -1
  133. package/out/builtins/tsGenerics.js +0 -26
  134. package/out/builtins/tsGenerics.js.map +0 -1
  135. package/out/builtins/tsKeywords.d.ts +0 -23
  136. package/out/builtins/tsKeywords.d.ts.map +0 -1
  137. package/out/builtins/tsKeywords.js +0 -23
  138. package/out/builtins/tsKeywords.js.map +0 -1
  139. package/out/builtins/utils/creditCard.d.ts +0 -3
  140. package/out/builtins/utils/creditCard.d.ts.map +0 -1
  141. package/out/builtins/utils/creditCard.js +0 -35
  142. package/out/builtins/utils/creditCard.js.map +0 -1
  143. package/out/builtins/utils/date.d.ts +0 -41
  144. package/out/builtins/utils/date.d.ts.map +0 -1
  145. package/out/builtins/utils/date.js +0 -56
  146. package/out/builtins/utils/date.js.map +0 -1
  147. package/out/builtins/validation.d.ts +0 -19
  148. package/out/builtins/validation.d.ts.map +0 -1
  149. package/out/builtins/validation.js +0 -74
  150. package/out/builtins/validation.js.map +0 -1
  151. package/out/config.d.ts +0 -9
  152. package/out/config.d.ts.map +0 -1
  153. package/out/config.js +0 -18
  154. package/out/config.js.map +0 -1
  155. package/out/constraints/ast.d.ts +0 -287
  156. package/out/constraints/ast.d.ts.map +0 -1
  157. package/out/constraints/ast.js +0 -2
  158. package/out/constraints/ast.js.map +0 -1
  159. package/out/constraints/constraint.d.ts +0 -200
  160. package/out/constraints/constraint.d.ts.map +0 -1
  161. package/out/constraints/constraint.js +0 -25
  162. package/out/constraints/constraint.js.map +0 -1
  163. package/out/constraints/predicate.d.ts +0 -64
  164. package/out/constraints/predicate.d.ts.map +0 -1
  165. package/out/constraints/predicate.js +0 -52
  166. package/out/constraints/predicate.js.map +0 -1
  167. package/out/constraints/props/index.d.ts +0 -42
  168. package/out/constraints/props/index.d.ts.map +0 -1
  169. package/out/constraints/props/index.js +0 -56
  170. package/out/constraints/props/index.js.map +0 -1
  171. package/out/constraints/props/optional.d.ts +0 -37
  172. package/out/constraints/props/optional.d.ts.map +0 -1
  173. package/out/constraints/props/optional.js +0 -56
  174. package/out/constraints/props/optional.js.map +0 -1
  175. package/out/constraints/props/prop.d.ts +0 -49
  176. package/out/constraints/props/prop.d.ts.map +0 -1
  177. package/out/constraints/props/prop.js +0 -106
  178. package/out/constraints/props/prop.js.map +0 -1
  179. package/out/constraints/props/props.d.ts +0 -37
  180. package/out/constraints/props/props.d.ts.map +0 -1
  181. package/out/constraints/props/props.js +0 -121
  182. package/out/constraints/props/props.js.map +0 -1
  183. package/out/constraints/props/required.d.ts +0 -46
  184. package/out/constraints/props/required.d.ts.map +0 -1
  185. package/out/constraints/props/required.js +0 -81
  186. package/out/constraints/props/required.js.map +0 -1
  187. package/out/constraints/props/sequence.d.ts +0 -82
  188. package/out/constraints/props/sequence.d.ts.map +0 -1
  189. package/out/constraints/props/sequence.js +0 -376
  190. package/out/constraints/props/sequence.js.map +0 -1
  191. package/out/constraints/props/shared.d.ts +0 -3
  192. package/out/constraints/props/shared.d.ts.map +0 -1
  193. package/out/constraints/props/shared.js +0 -4
  194. package/out/constraints/props/shared.js.map +0 -1
  195. package/out/constraints/refinements/after.d.ts +0 -33
  196. package/out/constraints/refinements/after.d.ts.map +0 -1
  197. package/out/constraints/refinements/after.js +0 -36
  198. package/out/constraints/refinements/after.js.map +0 -1
  199. package/out/constraints/refinements/before.d.ts +0 -33
  200. package/out/constraints/refinements/before.d.ts.map +0 -1
  201. package/out/constraints/refinements/before.js +0 -43
  202. package/out/constraints/refinements/before.js.map +0 -1
  203. package/out/constraints/refinements/divisor.d.ts +0 -52
  204. package/out/constraints/refinements/divisor.d.ts.map +0 -1
  205. package/out/constraints/refinements/divisor.js +0 -52
  206. package/out/constraints/refinements/divisor.js.map +0 -1
  207. package/out/constraints/refinements/exactLength.d.ts +0 -45
  208. package/out/constraints/refinements/exactLength.d.ts.map +0 -1
  209. package/out/constraints/refinements/exactLength.js +0 -52
  210. package/out/constraints/refinements/exactLength.js.map +0 -1
  211. package/out/constraints/refinements/kinds.d.ts +0 -29
  212. package/out/constraints/refinements/kinds.d.ts.map +0 -1
  213. package/out/constraints/refinements/kinds.js +0 -17
  214. package/out/constraints/refinements/kinds.js.map +0 -1
  215. package/out/constraints/refinements/length.d.ts +0 -48
  216. package/out/constraints/refinements/length.d.ts.map +0 -1
  217. package/out/constraints/refinements/length.js +0 -53
  218. package/out/constraints/refinements/length.js.map +0 -1
  219. package/out/constraints/refinements/max.d.ts +0 -31
  220. package/out/constraints/refinements/max.d.ts.map +0 -1
  221. package/out/constraints/refinements/max.js +0 -35
  222. package/out/constraints/refinements/max.js.map +0 -1
  223. package/out/constraints/refinements/maxLength.d.ts +0 -32
  224. package/out/constraints/refinements/maxLength.d.ts.map +0 -1
  225. package/out/constraints/refinements/maxLength.js +0 -36
  226. package/out/constraints/refinements/maxLength.js.map +0 -1
  227. package/out/constraints/refinements/min.d.ts +0 -31
  228. package/out/constraints/refinements/min.d.ts.map +0 -1
  229. package/out/constraints/refinements/min.js +0 -28
  230. package/out/constraints/refinements/min.js.map +0 -1
  231. package/out/constraints/refinements/minLength.d.ts +0 -32
  232. package/out/constraints/refinements/minLength.d.ts.map +0 -1
  233. package/out/constraints/refinements/minLength.js +0 -33
  234. package/out/constraints/refinements/minLength.js.map +0 -1
  235. package/out/constraints/refinements/range.d.ts +0 -119
  236. package/out/constraints/refinements/range.d.ts.map +0 -1
  237. package/out/constraints/refinements/range.js +0 -89
  238. package/out/constraints/refinements/range.js.map +0 -1
  239. package/out/constraints/refinements/regex.d.ts +0 -47
  240. package/out/constraints/refinements/regex.d.ts.map +0 -1
  241. package/out/constraints/refinements/regex.js +0 -37
  242. package/out/constraints/refinements/regex.js.map +0 -1
  243. package/out/constraints/refinements/shared.d.ts +0 -20
  244. package/out/constraints/refinements/shared.d.ts.map +0 -1
  245. package/out/constraints/refinements/shared.js +0 -10
  246. package/out/constraints/refinements/shared.js.map +0 -1
  247. package/out/generic.d.ts.map +0 -1
  248. package/out/inference.d.ts +0 -137
  249. package/out/inference.d.ts.map +0 -1
  250. package/out/inference.js +0 -73
  251. package/out/inference.js.map +0 -1
  252. package/out/keywords/ark.d.ts +0 -70
  253. package/out/keywords/ark.d.ts.map +0 -1
  254. package/out/keywords/ark.js +0 -29
  255. package/out/keywords/ark.js.map +0 -1
  256. package/out/keywords/internal.d.ts +0 -13
  257. package/out/keywords/internal.d.ts.map +0 -1
  258. package/out/keywords/internal.js +0 -13
  259. package/out/keywords/internal.js.map +0 -1
  260. package/out/keywords/jsObject.d.ts +0 -20
  261. package/out/keywords/jsObject.d.ts.map +0 -1
  262. package/out/keywords/jsObject.js +0 -18
  263. package/out/keywords/jsObject.js.map +0 -1
  264. package/out/keywords/parsing.d.ts +0 -17
  265. package/out/keywords/parsing.d.ts.map +0 -1
  266. package/out/keywords/parsing.js +0 -64
  267. package/out/keywords/parsing.js.map +0 -1
  268. package/out/keywords/root.d.ts +0 -7
  269. package/out/keywords/root.d.ts.map +0 -1
  270. package/out/keywords/root.js +0 -4
  271. package/out/keywords/root.js.map +0 -1
  272. package/out/keywords/tsGenerics.d.ts +0 -2
  273. package/out/keywords/tsGenerics.d.ts.map +0 -1
  274. package/out/keywords/tsGenerics.js +0 -26
  275. package/out/keywords/tsGenerics.js.map +0 -1
  276. package/out/keywords/tsPrimitive.d.ts +0 -24
  277. package/out/keywords/tsPrimitive.d.ts.map +0 -1
  278. package/out/keywords/tsPrimitive.js +0 -25
  279. package/out/keywords/tsPrimitive.js.map +0 -1
  280. package/out/keywords/utils/creditCard.d.ts +0 -11
  281. package/out/keywords/utils/creditCard.d.ts.map +0 -1
  282. package/out/keywords/utils/creditCard.js +0 -35
  283. package/out/keywords/utils/creditCard.js.map +0 -1
  284. package/out/keywords/utils/date.d.ts +0 -45
  285. package/out/keywords/utils/date.d.ts.map +0 -1
  286. package/out/keywords/utils/date.js +0 -56
  287. package/out/keywords/utils/date.js.map +0 -1
  288. package/out/keywords/validation.d.ts +0 -20
  289. package/out/keywords/validation.d.ts.map +0 -1
  290. package/out/keywords/validation.js +0 -80
  291. package/out/keywords/validation.js.map +0 -1
  292. package/out/kinds.d.ts +0 -102
  293. package/out/kinds.d.ts.map +0 -1
  294. package/out/kinds.js +0 -29
  295. package/out/kinds.js.map +0 -1
  296. package/out/main.d.ts.map +0 -1
  297. package/out/match.d.ts.map +0 -1
  298. package/out/module.d.ts.map +0 -1
  299. package/out/parse.d.ts +0 -29
  300. package/out/parse.d.ts.map +0 -1
  301. package/out/parse.js +0 -161
  302. package/out/parse.js.map +0 -1
  303. package/out/parser/definition.d.ts.map +0 -1
  304. package/out/parser/generic.d.ts.map +0 -1
  305. package/out/parser/objectLiteral.d.ts.map +0 -1
  306. package/out/parser/semantic/bounds.d.ts.map +0 -1
  307. package/out/parser/semantic/divisor.d.ts.map +0 -1
  308. package/out/parser/semantic/infer.d.ts.map +0 -1
  309. package/out/parser/semantic/utils.d.ts.map +0 -1
  310. package/out/parser/semantic/validate.d.ts.map +0 -1
  311. package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
  312. package/out/parser/string/reduce/shared.d.ts.map +0 -1
  313. package/out/parser/string/reduce/static.d.ts.map +0 -1
  314. package/out/parser/string/shift/operand/date.d.ts.map +0 -1
  315. package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
  316. package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
  317. package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
  318. package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
  319. package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
  320. package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
  321. package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
  322. package/out/parser/string/shift/scanner.d.ts.map +0 -1
  323. package/out/parser/string/string.d.ts.map +0 -1
  324. package/out/parser/tuple.d.ts.map +0 -1
  325. package/out/schema.d.ts +0 -175
  326. package/out/schema.d.ts.map +0 -1
  327. package/out/schema.js +0 -73
  328. package/out/schema.js.map +0 -1
  329. package/out/schemaScope.d.ts +0 -180
  330. package/out/schemaScope.d.ts.map +0 -1
  331. package/out/schemaScope.js +0 -235
  332. package/out/schemaScope.js.map +0 -1
  333. package/out/scope.d.ts.map +0 -1
  334. package/out/shared/compile.d.ts +0 -22
  335. package/out/shared/compile.d.ts.map +0 -1
  336. package/out/shared/compile.js +0 -79
  337. package/out/shared/compile.js.map +0 -1
  338. package/out/shared/context.d.ts +0 -54
  339. package/out/shared/context.d.ts.map +0 -1
  340. package/out/shared/context.js +0 -53
  341. package/out/shared/context.js.map +0 -1
  342. package/out/shared/declare.d.ts +0 -69
  343. package/out/shared/declare.d.ts.map +0 -1
  344. package/out/shared/declare.js +0 -2
  345. package/out/shared/declare.js.map +0 -1
  346. package/out/shared/disjoint.d.ts +0 -91
  347. package/out/shared/disjoint.d.ts.map +0 -1
  348. package/out/shared/disjoint.js +0 -110
  349. package/out/shared/disjoint.js.map +0 -1
  350. package/out/shared/errors.d.ts +0 -99
  351. package/out/shared/errors.d.ts.map +0 -1
  352. package/out/shared/errors.js +0 -108
  353. package/out/shared/errors.js.map +0 -1
  354. package/out/shared/implement.d.ts +0 -363
  355. package/out/shared/implement.d.ts.map +0 -1
  356. package/out/shared/implement.js +0 -68
  357. package/out/shared/implement.js.map +0 -1
  358. package/out/shared/inference.d.ts +0 -6
  359. package/out/shared/inference.d.ts.map +0 -1
  360. package/out/shared/inference.js +0 -5
  361. package/out/shared/inference.js.map +0 -1
  362. package/out/shared/intersections.d.ts +0 -60
  363. package/out/shared/intersections.d.ts.map +0 -1
  364. package/out/shared/intersections.js +0 -2
  365. package/out/shared/intersections.js.map +0 -1
  366. package/out/shared/traversal.d.ts +0 -62
  367. package/out/shared/traversal.d.ts.map +0 -1
  368. package/out/shared/traversal.js +0 -97
  369. package/out/shared/traversal.js.map +0 -1
  370. package/out/shared/utils.d.ts +0 -24
  371. package/out/shared/utils.d.ts.map +0 -1
  372. package/out/shared/utils.js +0 -15
  373. package/out/shared/utils.js.map +0 -1
  374. package/out/type.d.ts.map +0 -1
  375. package/out/types/basis.d.ts +0 -47
  376. package/out/types/basis.d.ts.map +0 -1
  377. package/out/types/basis.js +0 -15
  378. package/out/types/basis.js.map +0 -1
  379. package/out/types/discriminate.d.ts +0 -34
  380. package/out/types/discriminate.d.ts.map +0 -1
  381. package/out/types/discriminate.js +0 -120
  382. package/out/types/discriminate.js.map +0 -1
  383. package/out/types/domain.d.ts +0 -57
  384. package/out/types/domain.d.ts.map +0 -1
  385. package/out/types/domain.js +0 -41
  386. package/out/types/domain.js.map +0 -1
  387. package/out/types/intersection.d.ts +0 -127
  388. package/out/types/intersection.d.ts.map +0 -1
  389. package/out/types/intersection.js +0 -379
  390. package/out/types/intersection.js.map +0 -1
  391. package/out/types/morph.d.ts +0 -157
  392. package/out/types/morph.d.ts.map +0 -1
  393. package/out/types/morph.js +0 -99
  394. package/out/types/morph.js.map +0 -1
  395. package/out/types/proto.d.ts +0 -51
  396. package/out/types/proto.d.ts.map +0 -1
  397. package/out/types/proto.js +0 -60
  398. package/out/types/proto.js.map +0 -1
  399. package/out/types/type.d.ts +0 -143
  400. package/out/types/type.d.ts.map +0 -1
  401. package/out/types/type.js +0 -123
  402. package/out/types/type.js.map +0 -1
  403. package/out/types/union.d.ts +0 -71
  404. package/out/types/union.d.ts.map +0 -1
  405. package/out/types/union.js +0 -379
  406. package/out/types/union.js.map +0 -1
  407. package/out/types/unit.d.ts +0 -45
  408. package/out/types/unit.d.ts.map +0 -1
  409. package/out/types/unit.js +0 -56
  410. package/out/types/unit.js.map +0 -1
  411. package/out/util.d.ts +0 -31
  412. package/out/util.d.ts.map +0 -1
  413. package/out/util.js +0 -8
  414. package/out/util.js.map +0 -1
package/out/scope.js CHANGED
@@ -6,6 +6,7 @@ import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.
6
6
  import { parseGenericParams } from "./parser/generic.js";
7
7
  import { DynamicState } from "./parser/string/reduce/dynamic.js";
8
8
  import { fullStringParse } from "./parser/string/string.js";
9
+ import { RawTypeParser } from "./type.js";
9
10
  export const scope = ((def, config = {}) => new RawScope(def, config));
10
11
  export class RawScope extends RawSchemaScope {
11
12
  parseCache = {};
@@ -21,57 +22,35 @@ export class RawScope extends RawSchemaScope {
21
22
  }
22
23
  super(aliases, config);
23
24
  }
24
- type(...args) {
25
- if (args.length === 1) {
26
- // treat as a simple definition
27
- return this.parseRoot(args[0]);
28
- }
29
- if (args.length === 2 &&
30
- typeof args[0] === "string" &&
31
- args[0][0] === "<" &&
32
- args[0].at(-1) === ">") {
33
- // if there are exactly two args, the first of which looks like <${string}>,
34
- // treat as a generic
35
- const params = parseGenericParams(args[0].slice(1, -1));
36
- const def = args[1];
37
- // TODO: validateUninstantiatedGeneric, remove this cast
38
- return new Generic(params, def, this);
39
- }
40
- // otherwise, treat as a tuple expression. technically, this also allows
41
- // non-expression tuple definitions to be parsed, but it's not a supported
42
- // part of the API as specified by the associated types
43
- return this.parseRoot(args);
44
- }
25
+ type = new RawTypeParser(this);
45
26
  match = createMatchParser(this);
46
- declare() {
47
- return { type: this.type.bind(this) };
48
- }
49
- define(def) {
50
- return def;
51
- }
27
+ declare = (() => ({
28
+ type: this.type
29
+ })).bind(this);
30
+ define = ((def) => def).bind(this);
52
31
  preparseRoot(def) {
53
- if (isThunk(def) && !hasArkKind(def, "generic")) {
32
+ if (isThunk(def) && !hasArkKind(def, "generic"))
54
33
  return def();
55
- }
56
34
  return def;
57
35
  }
58
- parseRoot(def, opts) {
36
+ parseRoot(def) {
37
+ // args: { this: {} as RawSchema },
59
38
  return this.parse(def, {
60
- args: { this: {} },
61
39
  $: this,
62
- ...opts
40
+ args: {}
41
+ // type parsing can bypass nodes if it hits the cache,
42
+ // so bind it directly (could be optimized)
63
43
  }).bindScope(this);
64
44
  }
65
45
  parse(def, ctx) {
66
46
  if (typeof def === "string") {
67
- if (ctx.args && Object.keys(ctx.args).every((k) => !def.includes(k))) {
47
+ if (ctx.args && Object.keys(ctx.args).every(k => !def.includes(k))) {
68
48
  // we can only rely on the cache if there are no contextual
69
49
  // resolutions like "this" or generic args
70
50
  return this.parseString(def, ctx);
71
51
  }
72
- if (!this.parseCache[def]) {
52
+ if (!this.parseCache[def])
73
53
  this.parseCache[def] = this.parseString(def, ctx);
74
- }
75
54
  return this.parseCache[def];
76
55
  }
77
56
  return hasDomain(def, "object") ?
@@ -79,9 +58,9 @@ export class RawScope extends RawSchemaScope {
79
58
  : throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
80
59
  }
81
60
  parseString(def, ctx) {
82
- return (this.maybeResolveNode(def) ??
61
+ return (this.maybeResolveSchema(def) ??
83
62
  ((def.endsWith("[]") &&
84
- this.maybeResolveNode(def.slice(0, -2))?.array()) ||
63
+ this.maybeResolveSchema(def.slice(0, -2))?.array()) ||
85
64
  fullStringParse(new DynamicState(def, ctx))));
86
65
  }
87
66
  }
@@ -102,4 +81,3 @@ export const parseScopeKey = (k) => {
102
81
  params: parseGenericParams(k.slice(firstParamIndex + 1, -1))
103
82
  };
104
83
  };
105
- //# sourceMappingURL=scope.js.map
package/out/scope.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EAOd,UAAU,EACV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEN,QAAQ,EACR,SAAS,EACT,OAAO,EAGP,eAAe,EACf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,YAAY,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AAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;gBACnD,eAAe,CAAC,IAAI,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAC7C,CAAA;IACF,CAAC;CACD;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,IAAY,EACZ,IAAc,EACL,EAAE,CACX,UAAU,IAAI,qCAAqC,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAO/E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAkB,EAAE;IAC1D,MAAM,eAAe,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACtC,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;QAC5B,OAAO;YACN,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,EAAE;SACV,CAAA;IACF,CAAC;IACD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACtB,eAAe,CACd,oEAAoE,CACpE,CAAA;IACF,CAAC;IACD,OAAO;QACN,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC;QACjC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5D,CAAA;AACF,CAAC,CAAA"}
package/out/type.d.ts CHANGED
@@ -1,37 +1,56 @@
1
- import { type BaseMeta, type Morph, type NodeDef, type Out, type Predicate, type PrimitiveConstraintKind, type Schema, type ambient, type constrain, type constraintKindOf, type distillConstrainableIn, type distillConstrainableOut, type distillIn, type distillOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
2
- import type { Constructor, array, conform } from "@arktype/util";
3
- import type { Generic, validateParameterString } from "./generic.js";
1
+ import { ArkErrors, type BaseMeta, type BaseRoot, type Disjoint, type Morph, type NodeDef, type Out, type Predicate, type PrimitiveConstraintKind, RawSchema, type Schema, type ambient, type constrain, type constraintKindOf, type distillConstrainableOut, type distillIn, type distillOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow, type inferPipes, type internalImplementationOf } from "@arktype/schema";
2
+ import { Callable, type Constructor, type array, type conform } from "@arktype/util";
3
+ import { Generic, type validateParameterString } from "./generic.js";
4
4
  import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.js";
5
- import type { parseGenericParams } from "./parser/generic.js";
5
+ import { parseGenericParams } from "./parser/generic.js";
6
6
  import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.js";
7
- import type { Scope, bindThis } from "./scope.js";
8
- export type TypeParser<$> = {
7
+ import type { RawScope, Scope, bindThis } from "./scope.js";
8
+ export interface TypeParserAttachments {
9
+ errors: typeof ArkErrors;
10
+ }
11
+ export interface TypeParser<$> extends TypeParserAttachments {
9
12
  <const def>(def: validateTypeRoot<def, $>): Type<inferTypeRoot<def, $>, $>;
10
13
  <const zero, const one, const rest extends array>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distillIn<inferTypeRoot<zero, $>>>] : one extends "=>" ? [Morph<distillOut<inferTypeRoot<zero, $>>, unknown>] : one extends "@" ? [string | BaseMeta] : [validateTypeRoot<rest[0], $>] : []): Type<inferTypeRoot<[zero, one, ...rest], $>, $>;
11
14
  <params extends string, const def>(params: `<${validateParameterString<params>}>`, def: validateDefinition<def, $, {
12
15
  [param in parseGenericParams<params>[number]]: unknown;
13
16
  }>): Generic<parseGenericParams<params>, def, $>;
14
- };
17
+ }
18
+ export declare class RawTypeParser extends Callable<(...args: unknown[]) => RawSchema | Generic, TypeParserAttachments> {
19
+ constructor($: RawScope);
20
+ }
15
21
  export type DeclarationParser<$> = <preinferred>() => {
16
22
  type: <def>(def: validateDeclared<preinferred, def, $ & ambient, bindThis<def>>) => Type<preinferred, $>;
17
23
  };
24
+ declare class _Type<t = unknown, $ = any> extends BaseRoot<t, $> implements internalImplementationOf<Schema> {
25
+ $: Scope<$>;
26
+ get in(): Type<this["tIn"], $>;
27
+ get out(): Type<this["tOut"], $>;
28
+ intersect<def>(def: validateTypeRoot<def, $>): Type<inferIntersection<t, inferTypeRoot<def, $>>> | Disjoint;
29
+ and<def>(def: validateTypeRoot<def, $>): Type<inferIntersection<t, inferTypeRoot<def, $>>, $>;
30
+ or<def>(def: validateTypeRoot<def, $>): Type<t | inferTypeRoot<def, $>, $>;
31
+ array(): Type<t[], $>;
32
+ keyof(): Type<keyof this["inferIn"], $>;
33
+ pipe<a extends Morph<this["infer"]>>(a: a): Type<inferPipes<t, [a]>, $>;
34
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>>(a: a, b: b): Type<inferPipes<t, [a, b]>, $>;
35
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>>(a: a, b: b, c: c): Type<inferPipes<t, [a, b, c]>, $>;
36
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>>(a: a, b: b, c: c, d: d): Type<inferPipes<t, [a, b, c, d]>, $>;
37
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>>(a: a, b: b, c: c, d: d, e: e): Type<inferPipes<t, [a, b, c, d, e]>, $>;
38
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>>(a: a, b: b, c: c, d: d, e: e, f: f): Type<inferPipes<t, [a, b, c, d, e, f]>, $>;
39
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): Type<inferPipes<t, [a, b, c, d, e, f, g]>, $>;
40
+ narrow<def extends Predicate<distillConstrainableOut<t>>>(def: def): Type<includesMorphs<t> extends true ? (In: this["tIn"]) => Out<inferNarrow<this["infer"], def>> : inferNarrow<this["infer"], def>, $>;
41
+ equals<def>(def: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def>, $>;
42
+ extract<def>(r: validateTypeRoot<def, $>): Type<t, $>;
43
+ exclude<def>(r: validateTypeRoot<def, $>): Type<t, $>;
44
+ extends<def>(other: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def>, $>;
45
+ constrain<kind extends PrimitiveConstraintKind, const def extends NodeDef<kind>>(kind: conform<kind, constraintKindOf<this["inferIn"]>>, def: def): Type<constrain<t, kind, def>, $>;
46
+ }
18
47
  export interface Type<
19
48
  /** @ts-expect-error allow instantiation assignment to the base type */
20
- out t = unknown, $ = any> extends Schema<t, $> {
21
- and: (<def>(def: validateTypeRoot<def, $>) => Type<inferIntersection<t, inferTypeRoot<def, $>>, $>) & Schema<t, $>["and"];
22
- or: (<def>(def: validateTypeRoot<def, $>) => Type<t | inferTypeRoot<def, $>, $>) & Schema<t, $>["or"];
23
- get in(): Type<distillConstrainableIn<t>, $>;
24
- get out(): Type<distillConstrainableOut<t>, $>;
25
- array(): Type<t[], $>;
26
- morph: (<morph extends Morph<this["infer"]>, outValidatorDef = never>(morph: morph, outValidator?: validateTypeRoot<outValidatorDef, $>) => Type<(In: distillConstrainableIn<t>) => Out<[
27
- outValidatorDef
28
- ] extends [never] ? inferMorphOut<morph> : distillConstrainableOut<inferTypeRoot<outValidatorDef, $>>>, $>) & Schema<t, $>["morph"];
29
- narrow<def extends Predicate<distillConstrainableOut<t>>>(def: def): Type<includesMorphs<t> extends true ? (In: distillIn<t>) => Out<inferNarrow<this["infer"], def>> : inferNarrow<this["infer"], def>, $>;
30
- constrain<kind extends PrimitiveConstraintKind, const def extends NodeDef<kind>>(kind: conform<kind, constraintKindOf<this["in"]["infer"]>>, def: def): Type<constrain<t, kind, def>, $>;
49
+ out t = unknown, $ = any> extends _Type<t, $> {
31
50
  }
32
51
  export type TypeConstructor<t = unknown, $ = any> = new (def: unknown, $: Scope<$>) => Type<t, $>;
33
52
  export declare const Type: TypeConstructor;
34
53
  export type DefinitionParser<$> = <def>(def: validateTypeRoot<def, $>) => def;
35
54
  export type validateTypeRoot<def, $ = {}> = validateDefinition<def, $ & ambient, bindThis<def>>;
36
55
  export type inferTypeRoot<def, $ = {}> = inferDefinition<def, $ & ambient, bindThis<def>>;
37
- //# sourceMappingURL=type.d.ts.map
56
+ export {};
package/out/type.js CHANGED
@@ -1,3 +1,33 @@
1
- import { RawSchema } from "@arktype/schema";
1
+ import { ArkErrors, RawSchema } from "@arktype/schema";
2
+ import { Callable } from "@arktype/util";
3
+ import { Generic } from "./generic.js";
4
+ import { parseGenericParams } from "./parser/generic.js";
5
+ const typeParserAttachments = Object.freeze({
6
+ errors: ArkErrors
7
+ });
8
+ export class RawTypeParser extends Callable {
9
+ constructor($) {
10
+ super((...args) => {
11
+ if (args.length === 1) {
12
+ // treat as a simple definition
13
+ return $.parseRoot(args[0]);
14
+ }
15
+ if (args.length === 2 &&
16
+ typeof args[0] === "string" &&
17
+ args[0][0] === "<" &&
18
+ args[0].at(-1) === ">") {
19
+ // if there are exactly two args, the first of which looks like <${string}>,
20
+ // treat as a generic
21
+ const params = parseGenericParams(args[0].slice(1, -1));
22
+ const def = args[1];
23
+ // TODO: validateUninstantiatedGeneric, remove this cast
24
+ return new Generic(params, def, $);
25
+ }
26
+ // otherwise, treat as a tuple expression. technically, this also allows
27
+ // non-expression tuple definitions to be parsed, but it's not a supported
28
+ // part of the API as specified by the associated types
29
+ return $.parseRoot(args);
30
+ }, { bind: $, attach: typeParserAttachments });
31
+ }
32
+ }
2
33
  export const Type = RawSchema;
3
- //# sourceMappingURL=type.js.map
package/out/type.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../type.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,SAAS,EAaT,MAAM,iBAAiB,CAAA;AAmHxB,MAAM,CAAC,MAAM,IAAI,GAAoB,SAAkB,CAAA"}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../type.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EAST,SAAS,EAcT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACN,QAAQ,EAIR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAAgC,MAAM,cAAc,CAAA;AAMpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AA8CxD,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,SAAS;CACe,CAAC,CAAA;AAElC,MAAM,OAAO,aAAc,SAAQ,QAGlC;IACA,YAAY,CAAW;QACtB,KAAK,CACJ,CAAC,GAAG,IAAI,EAAE,EAAE;YACX,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,+BAA+B;gBAC/B,OAAO,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAC5B,CAAC;YACD,IACC,IAAI,CAAC,MAAM,KAAK,CAAC;gBACjB,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAC3B,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;gBAClB,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EACrB,CAAC;gBACF,4EAA4E;gBAC5E,qBAAqB;gBACrB,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;gBACvD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;gBACnB,wDAAwD;gBACxD,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,CAAU,CAAU,CAAA;YACrD,CAAC;YACD,wEAAwE;YACxE,0EAA0E;YAC1E,uDAAuD;YACvD,OAAO,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC,EACD,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAC1C,CAAA;IACF,CAAC;CACD;AAoID,MAAM,CAAC,MAAM,IAAI,GAAoB,SAAkB,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "TypeScript's 1:1 validator, optimized from editor to runtime",
4
- "version": "2.0.0-dev.7",
4
+ "version": "2.0.0-dev.9",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "David Blass",
@@ -35,10 +35,12 @@
35
35
  ],
36
36
  "scripts": {
37
37
  "build": "tsx ../repo/build.ts",
38
- "test": "tsx ../repo/testPackage.ts"
38
+ "test": "tsx ../repo/testPackage.ts",
39
+ "latest": "npm dist-tag add arktype@1.0.29-alpha latest",
40
+ "devtag": "npm dist-tag add arktype@2.0.0-dev.8 dev"
39
41
  },
40
42
  "dependencies": {
41
- "@arktype/util": "0.0.33",
42
- "@arktype/schema": "0.0.7"
43
+ "@arktype/util": "0.0.35",
44
+ "@arktype/schema": "0.1.0"
43
45
  }
44
46
  }
package/parser/generic.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type nominal, throwParseError } from "@arktype/util"
1
+ import { type keyError, throwParseError } from "@arktype/util"
2
2
  import { writeUnexpectedCharacterMessage } from "./string/shift/operator/operator.js"
3
3
  import { Scanner } from "./string/shift/scanner.js"
4
4
 
@@ -9,14 +9,14 @@ export type GenericDeclaration<
9
9
 
10
10
  // we put the error in a tuple so that parseGenericParams always returns a string[]
11
11
  export type GenericParamsParseError<message extends string = string> = [
12
- nominal<message, "InvalidGenericParameters">
12
+ keyError<message>
13
13
  ]
14
14
 
15
15
  export const parseGenericParams = (def: string): string[] =>
16
- $parseGenericParams(new Scanner(def))
16
+ _parseGenericParams(new Scanner(def))
17
17
 
18
18
  export type parseGenericParams<def extends string> =
19
- $parseParams<def, "", []> extends infer result extends string[] ?
19
+ _parseParams<def, "", []> extends infer result extends string[] ?
20
20
  "" extends result[number] ?
21
21
  GenericParamsParseError<emptyGenericParameterMessage>
22
22
  : result
@@ -27,41 +27,40 @@ export const emptyGenericParameterMessage =
27
27
 
28
28
  export type emptyGenericParameterMessage = typeof emptyGenericParameterMessage
29
29
 
30
- const $parseGenericParams = (scanner: Scanner): string[] => {
30
+ const _parseGenericParams = (scanner: Scanner): string[] => {
31
31
  const param = scanner.shiftUntilNextTerminator()
32
- if (param === "") {
33
- throwParseError(emptyGenericParameterMessage)
34
- }
32
+ if (param === "") throwParseError(emptyGenericParameterMessage)
33
+
35
34
  scanner.shiftUntilNonWhitespace()
36
35
  const nextNonWhitespace = scanner.shift()
37
36
  return (
38
37
  nextNonWhitespace === "" ? [param]
39
- : nextNonWhitespace === "," ? [param, ...$parseGenericParams(scanner)]
38
+ : nextNonWhitespace === "," ? [param, ..._parseGenericParams(scanner)]
40
39
  : throwParseError(writeUnexpectedCharacterMessage(nextNonWhitespace, ","))
41
40
  )
42
41
  }
43
42
 
44
- type $parseParams<
43
+ type _parseParams<
45
44
  unscanned extends string,
46
45
  param extends string,
47
46
  result extends string[]
48
47
  > =
49
48
  unscanned extends `${infer lookahead}${infer nextUnscanned}` ?
50
- lookahead extends "," ? $parseParams<nextUnscanned, "", [...result, param]>
49
+ lookahead extends "," ? _parseParams<nextUnscanned, "", [...result, param]>
51
50
  : lookahead extends Scanner.WhiteSpaceToken ?
52
51
  param extends "" ?
53
52
  // if the next char is whitespace and we aren't in the middle of a param, skip to the next one
54
- $parseParams<Scanner.skipWhitespace<nextUnscanned>, "", result>
53
+ _parseParams<Scanner.skipWhitespace<nextUnscanned>, "", result>
55
54
  : Scanner.skipWhitespace<nextUnscanned> extends (
56
55
  `${infer nextNonWhitespace}${infer rest}`
57
56
  ) ?
58
57
  nextNonWhitespace extends "," ?
59
- $parseParams<rest, "", [...result, param]>
58
+ _parseParams<rest, "", [...result, param]>
60
59
  : GenericParamsParseError<
61
60
  writeUnexpectedCharacterMessage<nextNonWhitespace, ",">
62
61
  >
63
62
  : // params end with a single whitespace character, add the current token
64
63
  [...result, param]
65
- : $parseParams<nextUnscanned, `${param}${lookahead}`, result>
64
+ : _parseParams<nextUnscanned, `${param}${lookahead}`, result>
66
65
  : param extends "" ? result
67
66
  : [...result, param]
@@ -1,5 +1,5 @@
1
1
  import {
2
- type Node,
2
+ type NodeDef,
3
3
  type RawSchema,
4
4
  tsKeywords,
5
5
  type writeInvalidPropertyKeyMessage
@@ -11,6 +11,7 @@ import {
11
11
  type merge,
12
12
  printable,
13
13
  type show,
14
+ spliterate,
14
15
  stringAndSymbolicEntriesOf,
15
16
  throwParseError
16
17
  } from "@arktype/util"
@@ -21,8 +22,8 @@ import type { validateString } from "./semantic/validate.js"
21
22
  import { Scanner } from "./string/shift/scanner.js"
22
23
 
23
24
  export const parseObjectLiteral = (def: Dict, ctx: ParseContext): RawSchema => {
24
- const propNodes: Node<"prop">[] = []
25
- const indexNodes: Node<"index">[] = []
25
+ const propNodes: NodeDef<"prop">[] = []
26
+ const indexNodes: NodeDef<"index">[] = []
26
27
  // We only allow a spread operator to be used as the first key in an object
27
28
  // because to match JS behavior any keys before the spread are overwritten
28
29
  // by the values in the target object, so there'd be no useful purpose in having it
@@ -46,33 +47,44 @@ export const parseObjectLiteral = (def: Dict, ctx: ParseContext): RawSchema => {
46
47
  // We filter out keys from the spreadNode that will be defined later on this same object
47
48
  // because the currently parsed definition will overwrite them.
48
49
  spreadNode.prop?.forEach(
49
- (spreadRequired) =>
50
+ spreadRequired =>
50
51
  !parsedEntries.some(
51
52
  ({ inner: innerKey }) => innerKey === spreadRequired.key
52
53
  ) && propNodes.push(spreadRequired)
53
54
  )
54
55
  }
55
56
  for (const entry of parsedEntries) {
56
- if (entry.kind === "spread") {
57
- return throwParseError(nonLeadingSpreadError)
58
- }
57
+ if (entry.kind === "spread") return throwParseError(nonLeadingSpreadError)
59
58
 
60
59
  if (entry.kind === "index") {
61
60
  // handle key parsing first to match type behavior
62
61
  const key = ctx.$.parse(entry.inner, ctx)
63
62
  const value = ctx.$.parse(entry.value, ctx)
64
- const indexNode = ctx.$.node("index", { key, value })
65
- indexNodes.push(indexNode)
63
+
64
+ // extract enumerable named props from the index signature
65
+ const [enumerable, nonEnumerable] = spliterate(key.branches, k =>
66
+ k.hasKind("unit")
67
+ )
68
+
69
+ if (enumerable.length) {
70
+ propNodes.push(
71
+ ...enumerable.map(k =>
72
+ ctx.$.node("prop", { key: k.unit as Key, value })
73
+ )
74
+ )
75
+ if (nonEnumerable.length)
76
+ indexNodes.push(ctx.$.node("index", { key: nonEnumerable, value }))
77
+ } else indexNodes.push(ctx.$.node("index", { key, value }))
66
78
  } else {
67
79
  const value = ctx.$.parse(entry.value, ctx)
68
- const propNode = ctx.$.node("prop", {
80
+ propNodes.push({
69
81
  key: entry.inner,
70
82
  value,
71
83
  optional: entry.kind === "optional"
72
84
  })
73
- propNodes.push(propNode)
74
85
  }
75
86
  }
87
+
76
88
  return ctx.$.schema({
77
89
  domain: "object",
78
90
  prop: propNodes,
@@ -172,6 +184,8 @@ const parseKey = (key: Key): PreparsedKey =>
172
184
  }
173
185
  : key[0] === "[" && key.at(-1) === "]" ?
174
186
  { inner: key.slice(1, -1), kind: "index" }
187
+ : key[0] === Scanner.escapeToken && key[1] === "[" && key.at(-1) === "]" ?
188
+ { inner: key.slice(1), kind: "required" }
175
189
  : key === "..." ? { inner: "...", kind: "spread" }
176
190
  : { inner: key === "\\..." ? "..." : key, kind: "required" }
177
191
 
@@ -9,6 +9,7 @@ import type {
9
9
  charsAfterFirst,
10
10
  Completion,
11
11
  ErrorMessage,
12
+ isAnyOrNever,
12
13
  writeMalformedNumericLiteralMessage
13
14
  } from "@arktype/util"
14
15
  import type { Comparator } from "../string/reduce/shared.js"
@@ -81,9 +82,7 @@ type validateStringAst<def extends string, $> =
81
82
  ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">>
82
83
  : undefined
83
84
  : maybeExtractAlias<def, $> extends infer alias extends keyof $ ?
84
- $[alias] extends null ?
85
- // handle any/never
86
- def
85
+ isAnyOrNever<$[alias]> extends true ? def
87
86
  : def extends PrivateDeclaration ?
88
87
  ErrorMessage<writePrefixedPrivateReferenceMessage<def>>
89
88
  : // these problems would've been caught during a fullStringParse, but it's most
@@ -77,18 +77,17 @@ export class DynamicState {
77
77
  }
78
78
 
79
79
  finalize(finalizer: Scanner.FinalizingLookahead): void {
80
- if (this.groups.length) {
81
- return this.error(writeUnclosedGroupMessage(")"))
82
- }
80
+ if (this.groups.length) return this.error(writeUnclosedGroupMessage(")"))
81
+
83
82
  this.finalizeBranches()
84
83
  this.finalizer = finalizer
85
84
  }
86
85
 
87
86
  reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void {
88
87
  const invertedComparator = invertedComparators[comparator]
89
- if (!isKeyOf(invertedComparator, minComparators)) {
88
+ if (!isKeyOf(invertedComparator, minComparators))
90
89
  return this.error(writeUnpairableComparatorMessage(comparator))
91
- }
90
+
92
91
  if (this.branches.leftBound) {
93
92
  return this.error(
94
93
  writeMultipleLeftBoundsMessage(
@@ -113,17 +112,15 @@ export class DynamicState {
113
112
  } else if (this.branches.intersection) {
114
113
  this.pushRootToBranch("&")
115
114
  this.root = this.branches.intersection
116
- } else {
117
- this.applyPrefixes()
118
- }
115
+ } else this.applyPrefixes()
119
116
  }
120
117
 
121
118
  finalizeGroup(): void {
122
119
  this.finalizeBranches()
123
120
  const topBranchState = this.groups.pop()
124
- if (!topBranchState) {
121
+ if (!topBranchState)
125
122
  return this.error(writeUnmatchedGroupCloseMessage(this.scanner.unscanned))
126
- }
123
+
127
124
  this.branches = topBranchState
128
125
  }
129
126
 
@@ -40,15 +40,12 @@ const maybeParseDate = <errorOnFail extends boolean | string>(
40
40
  errorOnFail?: errorOnFail
41
41
  ): DateParseResult<errorOnFail> => {
42
42
  const stringParsedDate = new Date(source)
43
- if (isValidDate(stringParsedDate)) {
44
- return stringParsedDate
45
- }
43
+ if (isValidDate(stringParsedDate)) return stringParsedDate
44
+
46
45
  const epochMillis = tryParseNumber(source)
47
46
  if (epochMillis !== undefined) {
48
47
  const numberParsedDate = new Date(epochMillis)
49
- if (isValidDate(numberParsedDate)) {
50
- return numberParsedDate
51
- }
48
+ if (isValidDate(numberParsedDate)) return numberParsedDate
52
49
  }
53
50
  return errorOnFail ?
54
51
  throwParseError(
@@ -21,11 +21,11 @@ export const parseEnclosed = (
21
21
  const enclosed = s.scanner.shiftUntil(
22
22
  untilLookaheadIsClosing[enclosingTokens[enclosing]]
23
23
  )
24
- if (s.scanner.lookahead === "") {
24
+ if (s.scanner.lookahead === "")
25
25
  return s.error(writeUnterminatedEnclosedMessage(enclosed, enclosing))
26
- }
26
+
27
27
  // Shift the scanner one additional time for the second enclosing token
28
- const token = `${enclosing}${enclosed}${s.scanner.shift()}`
28
+ s.scanner.shift()
29
29
  if (enclosing === "/") {
30
30
  // fail parsing if the regex is invalid
31
31
  new RegExp(enclosed)
@@ -37,9 +37,9 @@ export const parseEnclosed = (
37
37
  },
38
38
  { prereduced: true }
39
39
  )
40
- } else if (isKeyOf(enclosing, enclosingQuote)) {
40
+ } else if (isKeyOf(enclosing, enclosingQuote))
41
41
  s.root = s.ctx.$.node("unit", { unit: enclosed })
42
- } else {
42
+ else {
43
43
  const date = tryParseDate(enclosed, writeInvalidDateMessage(enclosed))
44
44
  s.root = s.ctx.$.node("unit", { unit: date, description: enclosed })
45
45
  }
@@ -93,9 +93,9 @@ export const untilLookaheadIsClosing: Record<
93
93
  EnclosingEndToken,
94
94
  Scanner.UntilCondition
95
95
  > = {
96
- "'": (scanner) => scanner.lookahead === `'`,
97
- '"': (scanner) => scanner.lookahead === `"`,
98
- "/": (scanner) => scanner.lookahead === `/`
96
+ "'": scanner => scanner.lookahead === `'`,
97
+ '"': scanner => scanner.lookahead === `"`,
98
+ "/": scanner => scanner.lookahead === `/`
99
99
  }
100
100
 
101
101
  const enclosingCharDescriptions = {
@@ -17,7 +17,7 @@ export const parseGenericArgs = (
17
17
  name: string,
18
18
  params: string[],
19
19
  s: DynamicState
20
- ): ParsedArgs<RawSchema[]> => $parseGenericArgs(name, params, s, [], [])
20
+ ): ParsedArgs<RawSchema[]> => _parseGenericArgs(name, params, s, [], [])
21
21
 
22
22
  export type parseGenericArgs<
23
23
  name extends string,
@@ -25,9 +25,9 @@ export type parseGenericArgs<
25
25
  unscanned extends string,
26
26
  $,
27
27
  args
28
- > = $parseGenericArgs<name, params, unscanned, $, args, [], []>
28
+ > = _parseGenericArgs<name, params, unscanned, $, args, [], []>
29
29
 
30
- const $parseGenericArgs = (
30
+ const _parseGenericArgs = (
31
31
  name: string,
32
32
  params: string[],
33
33
  s: DynamicState,
@@ -47,13 +47,13 @@ const $parseGenericArgs = (
47
47
  }
48
48
  return argState.error(writeInvalidGenericArgsMessage(name, params, argDefs))
49
49
  }
50
- if (argState.finalizer === ",") {
51
- return $parseGenericArgs(name, params, s, argDefs, argNodes)
52
- }
50
+ if (argState.finalizer === ",")
51
+ return _parseGenericArgs(name, params, s, argDefs, argNodes)
52
+
53
53
  return argState.error(writeUnclosedGroupMessage(">"))
54
54
  }
55
55
 
56
- type $parseGenericArgs<
56
+ type _parseGenericArgs<
57
57
  name extends string,
58
58
  params extends string[],
59
59
  unscanned extends string,
@@ -85,7 +85,7 @@ type $parseGenericArgs<
85
85
  ParsedArgs<nextAsts, nextUnscanned>
86
86
  : state.error<writeInvalidGenericArgsMessage<name, params, nextDefs>>
87
87
  : finalArgState["finalizer"] extends "," ?
88
- $parseGenericArgs<
88
+ _parseGenericArgs<
89
89
  name,
90
90
  params,
91
91
  nextUnscanned,