arktype 3.0.0-beta.1 → 3.0.0-rc.0

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 (312) hide show
  1. package/README.md +48 -144
  2. package/out/_internal/regex/charset.d.ts +24 -0
  3. package/out/_internal/regex/escape.d.ts +29 -0
  4. package/out/_internal/regex/execArray.d.ts +24 -0
  5. package/out/_internal/regex/group.d.ts +34 -0
  6. package/out/_internal/regex/index.d.ts +2 -0
  7. package/out/_internal/regex/internal.d.ts +9 -0
  8. package/out/_internal/regex/parse.d.ts +10 -0
  9. package/out/_internal/regex/quantify.d.ts +59 -0
  10. package/out/_internal/regex/regex.d.ts +38 -0
  11. package/out/_internal/regex/state.d.ts +383 -0
  12. package/out/_internal/schema/codecs.d.ts +2 -0
  13. package/out/_internal/schema/config.d.ts +103 -0
  14. package/out/_internal/schema/constraint.d.ts +78 -0
  15. package/out/_internal/schema/errors.d.ts +1 -0
  16. package/out/_internal/schema/generic.d.ts +85 -0
  17. package/out/_internal/schema/i18n.d.ts +3 -0
  18. package/out/_internal/schema/index.d.ts +54 -0
  19. package/out/_internal/schema/internal.d.ts +15 -0
  20. package/out/_internal/schema/intrinsic.d.ts +28 -0
  21. package/out/_internal/schema/kinds.d.ts +76 -0
  22. package/out/_internal/schema/module.d.ts +23 -0
  23. package/out/_internal/schema/mutatesInput.d.ts +2 -0
  24. package/out/_internal/schema/node.d.ts +349 -0
  25. package/out/_internal/schema/parse.d.ts +77 -0
  26. package/out/_internal/schema/parseSchema.d.ts +116 -0
  27. package/out/_internal/schema/predicate.d.ts +46 -0
  28. package/out/_internal/schema/refinements/after.d.ts +32 -0
  29. package/out/_internal/schema/refinements/before.d.ts +32 -0
  30. package/out/_internal/schema/refinements/divisor.d.ts +41 -0
  31. package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
  32. package/out/_internal/schema/refinements/kinds.d.ts +40 -0
  33. package/out/_internal/schema/refinements/max.d.ts +33 -0
  34. package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
  35. package/out/_internal/schema/refinements/min.d.ts +33 -0
  36. package/out/_internal/schema/refinements/minLength.d.ts +32 -0
  37. package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
  38. package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
  39. package/out/_internal/schema/refinements/pattern.d.ts +43 -0
  40. package/out/_internal/schema/refinements/range.d.ts +101 -0
  41. package/out/_internal/schema/roots/alias.d.ts +49 -0
  42. package/out/_internal/schema/roots/basis.d.ts +12 -0
  43. package/out/_internal/schema/roots/domain.d.ts +45 -0
  44. package/out/_internal/schema/roots/intersection.d.ts +72 -0
  45. package/out/_internal/schema/roots/morph.d.ts +59 -0
  46. package/out/_internal/schema/roots/proto.d.ts +42 -0
  47. package/out/_internal/schema/roots/root.d.ts +163 -0
  48. package/out/_internal/schema/roots/union.d.ts +146 -0
  49. package/out/_internal/schema/roots/unit.d.ts +36 -0
  50. package/out/_internal/schema/runtime.d.ts +29 -0
  51. package/out/_internal/schema/runtimeLean.d.ts +2 -0
  52. package/out/_internal/schema/runtimeNone.d.ts +2 -0
  53. package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
  54. package/out/_internal/schema/scope.d.ts +203 -0
  55. package/out/_internal/schema/shared/codecs.d.ts +5 -0
  56. package/out/_internal/schema/shared/compile.d.ts +144 -0
  57. package/out/_internal/schema/shared/configured.d.ts +14 -0
  58. package/out/_internal/schema/shared/declare.d.ts +100 -0
  59. package/out/_internal/schema/shared/disjoint.d.ts +45 -0
  60. package/out/_internal/schema/shared/enWriters.d.ts +30 -0
  61. package/out/_internal/schema/shared/errorModes.d.ts +25 -0
  62. package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
  63. package/out/_internal/schema/shared/errors.d.ts +264 -0
  64. package/out/_internal/schema/shared/implement.d.ts +154 -0
  65. package/out/_internal/schema/shared/inPlace.d.ts +8 -0
  66. package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
  67. package/out/_internal/schema/shared/issues.d.ts +261 -0
  68. package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
  69. package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
  70. package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
  71. package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
  72. package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
  73. package/out/_internal/schema/shared/listed.d.ts +15 -0
  74. package/out/_internal/schema/shared/locale.d.ts +149 -0
  75. package/out/_internal/schema/shared/registry.d.ts +16 -0
  76. package/out/_internal/schema/shared/render.d.ts +3 -0
  77. package/out/_internal/schema/shared/rootApply.d.ts +19 -0
  78. package/out/_internal/schema/shared/sets.d.ts +26 -0
  79. package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
  80. package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
  81. package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
  82. package/out/_internal/schema/shared/transform.d.ts +35 -0
  83. package/out/_internal/schema/shared/traversal.d.ts +288 -0
  84. package/out/_internal/schema/shared/utils.d.ts +59 -0
  85. package/out/_internal/schema/structure/index.d.ts +43 -0
  86. package/out/_internal/schema/structure/optional.d.ts +61 -0
  87. package/out/_internal/schema/structure/prop.d.ts +45 -0
  88. package/out/_internal/schema/structure/required.d.ts +49 -0
  89. package/out/_internal/schema/structure/sequence.d.ts +127 -0
  90. package/out/_internal/schema/structure/shared.d.ts +3 -0
  91. package/out/_internal/schema/structure/structure.d.ts +178 -0
  92. package/out/_internal/schema/units.d.ts +123 -0
  93. package/out/_internal/sets/algebra.d.ts +26 -0
  94. package/out/_internal/sets/constraint.d.ts +19 -0
  95. package/out/_internal/sets/engine.d.ts +2 -0
  96. package/out/_internal/sets/formats.d.ts +23 -0
  97. package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
  98. package/out/_internal/sets/implement.d.ts +16 -0
  99. package/out/_internal/sets/index.d.ts +2 -0
  100. package/out/_internal/sets/internal.d.ts +20 -0
  101. package/out/_internal/sets/intersections.d.ts +5 -0
  102. package/out/_internal/sets/kinds.d.ts +3 -0
  103. package/out/_internal/sets/refinements.d.ts +14 -0
  104. package/out/_internal/sets/roots/alias.d.ts +3 -0
  105. package/out/_internal/sets/roots/domain.d.ts +3 -0
  106. package/out/_internal/sets/roots/intersection.d.ts +4 -0
  107. package/out/_internal/sets/roots/morph.d.ts +4 -0
  108. package/out/_internal/sets/roots/proto.d.ts +3 -0
  109. package/out/_internal/sets/roots/union.d.ts +16 -0
  110. package/out/_internal/sets/roots/unit.d.ts +3 -0
  111. package/out/_internal/sets/structure/index.d.ts +3 -0
  112. package/out/_internal/sets/structure/prop.d.ts +8 -0
  113. package/out/_internal/sets/structure/sequence.d.ts +3 -0
  114. package/out/_internal/sets/structure/structure.d.ts +3 -0
  115. package/out/_internal/sets/toJsonSchema.d.ts +25 -0
  116. package/out/_internal/util/arrays.d.ts +130 -0
  117. package/out/_internal/util/clone.d.ts +4 -0
  118. package/out/_internal/util/describe.d.ts +25 -0
  119. package/out/_internal/util/domain.d.ts +49 -0
  120. package/out/_internal/util/errors.d.ts +29 -0
  121. package/out/_internal/util/facts.d.ts +22 -0
  122. package/out/_internal/util/flatMorph.d.ts +41 -0
  123. package/out/_internal/util/formats.d.ts +8 -0
  124. package/out/_internal/util/functions.d.ts +33 -0
  125. package/out/_internal/util/generics.d.ts +65 -0
  126. package/out/_internal/util/get.d.ts +9 -0
  127. package/out/_internal/util/hkt.d.ts +27 -0
  128. package/out/_internal/util/i18n.d.ts +12 -0
  129. package/out/_internal/util/index.d.ts +28 -0
  130. package/out/_internal/util/internal.d.ts +2 -0
  131. package/out/_internal/util/intersections.d.ts +50 -0
  132. package/out/_internal/util/isomorphic.d.ts +8 -0
  133. package/out/_internal/util/keys.d.ts +18 -0
  134. package/out/_internal/util/lazily.d.ts +7 -0
  135. package/out/_internal/util/numbers.d.ts +82 -0
  136. package/out/_internal/util/objectKinds.d.ts +157 -0
  137. package/out/_internal/util/path.d.ts +16 -0
  138. package/out/_internal/util/primitive.d.ts +16 -0
  139. package/out/_internal/util/records.d.ts +173 -0
  140. package/out/_internal/util/registry.d.ts +13 -0
  141. package/out/_internal/util/scanner.d.ts +110 -0
  142. package/out/_internal/util/serialize.d.ts +40 -0
  143. package/out/_internal/util/strings.d.ts +35 -0
  144. package/out/_internal/util/traits.d.ts +89 -0
  145. package/out/_internal/util/unionToTuple.d.ts +14 -0
  146. package/out/_internal/util/weak.d.ts +8 -0
  147. package/out/attributes.d.ts +15 -11
  148. package/out/checkers.d.ts +1 -1
  149. package/out/chunk-22RQSVV3.js +0 -0
  150. package/out/chunk-3HZC67MT.js +965 -0
  151. package/out/chunk-3KBOPH3J.js +1564 -0
  152. package/out/chunk-3SH2BQ4T.js +15 -0
  153. package/out/chunk-46PLKNON.js +126 -0
  154. package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
  155. package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
  156. package/out/chunk-4NZCLVBD.js +14 -0
  157. package/out/chunk-6FMBO47M.js +7 -0
  158. package/out/chunk-7TALAWYX.js +10 -0
  159. package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
  160. package/out/chunk-BDJVONP7.js +168 -0
  161. package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
  162. package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
  163. package/out/chunk-C3B4IFQL.js +6408 -0
  164. package/out/chunk-CWSF57VM.js +10 -0
  165. package/out/chunk-F5BACUJS.js +7 -0
  166. package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
  167. package/out/chunk-GID3FSQA.js +161 -0
  168. package/out/chunk-I2KLQ2HA.js +22 -0
  169. package/out/chunk-K7SLP5D2.js +84 -0
  170. package/out/chunk-KQPSKGUI.js +9 -0
  171. package/out/chunk-KXOC3JEX.js +8234 -0
  172. package/out/chunk-KXOSUYRA.js +405 -0
  173. package/out/chunk-LHNEY6QW.js +0 -0
  174. package/out/chunk-MTWKGAGO.js +323 -0
  175. package/out/chunk-NU73GNCX.js +170 -0
  176. package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
  177. package/out/chunk-PDLTEX6Z.js +1118 -0
  178. package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
  179. package/out/chunk-R7WXIH5P.js +94 -0
  180. package/out/chunk-TACLEIDM.js +95 -0
  181. package/out/chunk-UJJGG4VQ.js +71 -0
  182. package/out/chunk-US6BWOGJ.js +109 -0
  183. package/out/chunk-VMMMOO4R.js +945 -0
  184. package/out/chunk-VYMXHSFR.js +439 -0
  185. package/out/chunk-W2XOI5DY.js +141 -0
  186. package/out/chunk-WC5L5YRP.js +25 -0
  187. package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
  188. package/out/chunk-XLG66ZDF.js +0 -0
  189. package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
  190. package/out/chunk-ZRYEHGSG.js +79 -0
  191. package/out/cli.d.ts +28 -0
  192. package/out/cli.js +636 -0
  193. package/out/codecs.d.ts +6 -5
  194. package/out/codecs.js +23 -7
  195. package/out/config.d.ts +5 -17
  196. package/out/config.js +11 -2
  197. package/out/declare.d.ts +40 -12
  198. package/out/deferred.d.ts +2 -2
  199. package/out/errors.d.ts +1 -1
  200. package/out/errors.js +10 -2
  201. package/out/fn.d.ts +20 -13
  202. package/out/fromJsonSchema.d.ts +18 -0
  203. package/out/generic.d.ts +9 -6
  204. package/out/i18n.d.ts +2 -2
  205. package/out/i18n.js +9 -2
  206. package/out/index.d.ts +16 -7
  207. package/out/index.js +25 -8
  208. package/out/internal.d.ts +4 -0
  209. package/out/internal.js +41 -17
  210. package/out/island.js +22 -6
  211. package/out/islandDependency.js +42 -18
  212. package/out/jsonSchema/infer.d.ts +805 -0
  213. package/out/jsonSchema/validate.d.ts +416 -0
  214. package/out/keywords/Array.d.ts +2 -2
  215. package/out/keywords/builtins.d.ts +3 -3
  216. package/out/keywords/constructors.d.ts +1 -1
  217. package/out/keywords/functions.d.ts +5 -192
  218. package/out/keywords/keywords.d.ts +3 -3
  219. package/out/keywords/number.d.ts +2 -2
  220. package/out/keywords/phrases.d.ts +4 -191
  221. package/out/keywords/string.d.ts +3 -3
  222. package/out/keywords/ts.d.ts +18 -18
  223. package/out/keywords/ts.js +19 -4
  224. package/out/locale.d.ts +6 -2
  225. package/out/locales/de.js +9 -2
  226. package/out/locales/en.js +21 -5
  227. package/out/match.d.ts +13 -10
  228. package/out/module.d.ts +2 -2
  229. package/out/mutatesInput.js +18 -3
  230. package/out/nary.d.ts +220 -194
  231. package/out/parser/ast/bounds.d.ts +2 -2
  232. package/out/parser/ast/default.d.ts +2 -2
  233. package/out/parser/ast/divisor.d.ts +2 -2
  234. package/out/parser/ast/generic.d.ts +2 -2
  235. package/out/parser/ast/infer.d.ts +1 -1
  236. package/out/parser/ast/keyof.d.ts +2 -2
  237. package/out/parser/ast/utils.d.ts +1 -1
  238. package/out/parser/ast/validate.d.ts +2 -2
  239. package/out/parser/definition.d.ts +4 -4
  240. package/out/parser/objectLiteral.d.ts +2 -2
  241. package/out/parser/property.d.ts +2 -2
  242. package/out/parser/reduce/dynamic.d.ts +2 -2
  243. package/out/parser/reduce/shared.d.ts +1 -1
  244. package/out/parser/reduce/static.d.ts +1 -1
  245. package/out/parser/shift/operand/enclosed.d.ts +2 -2
  246. package/out/parser/shift/operand/genericArgs.d.ts +2 -2
  247. package/out/parser/shift/operand/operand.d.ts +1 -1
  248. package/out/parser/shift/operand/unenclosed.d.ts +2 -2
  249. package/out/parser/shift/operand/unresolvable.d.ts +2 -2
  250. package/out/parser/shift/operator/bounds.d.ts +2 -2
  251. package/out/parser/shift/operator/brand.d.ts +2 -2
  252. package/out/parser/shift/operator/default.d.ts +4 -4
  253. package/out/parser/shift/operator/divisor.d.ts +1 -1
  254. package/out/parser/shift/operator/operator.d.ts +1 -1
  255. package/out/parser/shift/tokens.d.ts +1 -1
  256. package/out/parser/string.d.ts +2 -2
  257. package/out/parser/tupleExpressions.d.ts +6 -8
  258. package/out/parser/tupleLiteral.d.ts +2 -2
  259. package/out/precompiled.d.ts +1 -1
  260. package/out/precompiled.js +16 -2
  261. package/out/regex.d.ts +1 -0
  262. package/out/regex.js +2 -0
  263. package/out/runtime.d.ts +10 -8
  264. package/out/runtime.js +6 -4
  265. package/out/runtimeDevelopment.js +70 -52
  266. package/out/schema.d.ts +1 -0
  267. package/out/schema.js +15 -0
  268. package/out/schemaInternal.d.ts +1 -0
  269. package/out/schemaInternal.js +1401 -0
  270. package/out/schemaIssueFeatures.d.ts +1 -0
  271. package/out/schemaRuntime.d.ts +1 -0
  272. package/out/schemaRuntime.js +7 -0
  273. package/out/schemaRuntimeLean.d.ts +1 -0
  274. package/out/schemaRuntimeLean.js +1870 -0
  275. package/out/schemaRuntimeNone.d.ts +1 -0
  276. package/out/schemaRuntimeNone.js +1774 -0
  277. package/out/schemaRuntimeNoneLean.d.ts +1 -0
  278. package/out/schemaRuntimeNoneLean.js +1767 -0
  279. package/out/scope.d.ts +3 -4
  280. package/out/shared/issueFeatures.d.ts +38 -0
  281. package/out/shared/issueFeatures.js +40 -0
  282. package/out/standalone/artifact.d.ts +6 -6
  283. package/out/standalone/baking.d.ts +2 -2
  284. package/out/standalone/combinators.d.ts +1 -1
  285. package/out/standalone/compilers.d.ts +1 -1
  286. package/out/standalone/fallbacks.d.ts +1 -1
  287. package/out/standalone/keys.d.ts +1 -1
  288. package/out/standalone/sites.d.ts +3 -3
  289. package/out/standalone/units.d.ts +1 -1
  290. package/out/standalone/values.d.ts +1 -1
  291. package/out/type.d.ts +6 -6
  292. package/out/util.d.ts +1 -0
  293. package/out/util.js +137 -0
  294. package/out/variants/array.d.ts +6 -6
  295. package/out/variants/base.d.ts +61 -10
  296. package/out/variants/date.d.ts +5 -5
  297. package/out/variants/instantiate.d.ts +1 -1
  298. package/out/variants/number.d.ts +6 -6
  299. package/out/variants/object.d.ts +25 -12
  300. package/out/variants/string.d.ts +8 -8
  301. package/package.json +183 -8
  302. package/skills/arktype/SKILL.md +93 -93
  303. package/skills/arktype/references/migrating.md +144 -158
  304. package/skills/arktype/references/precompile.md +7 -7
  305. package/out/chunk-4CUA5XIP.js +0 -7
  306. package/out/chunk-GPNK5353.js +0 -2529
  307. package/out/chunk-MLKGABMK.js +0 -9
  308. package/out/chunk-PRTMQCHS.js +0 -3
  309. package/out/chunk-R5G57XC7.js +0 -7
  310. package/out/chunk-SWOOCAHN.js +0 -4
  311. package/out/chunk-TAHPKDNM.js +0 -3
  312. package/out/chunk-UETB6YE2.js +0 -14
@@ -23,16 +23,16 @@ If asked to precompile too, set it up last, as [references/precompile.md](refere
23
23
 
24
24
  Follow https://arktype.io/docs/upgrading.md, whose checklist links each breaking change. What most code hits:
25
25
 
26
- | ArkType 2 | ArkType 3 |
27
- | -------------------------------------------------------------- | -------------------------------------------------------------------------- |
28
- | `out[0]`, `out.length`, `out.map(...)`, `for (const e of out)` | the same on `out.issues` |
29
- | `error.message`, for text naming its path | `out.summary`, a line per error; `error.message` now leaves the path out |
30
- | `error.problem`, `{ problem: "..." }` | `error.message`, `{ message: "..." }`, reworded as a whole sentence |
31
- | `out.flatProblemsByPath`, `out.byPath`, `out.flatByPath` | `flatMessagesByPath(out)`, `byPath(out)`, `flatByPath(out)` from `arktype` |
32
- | `out.message`, `out.toTraversalError()` | `out.summary`, `new TraversalError(out)` |
33
- | `error.hasCode("min")`, `error.toString()` | `error.code === "min"`, `error.message`: errors are plain objects |
34
- | `ctx.errors.add(...)` | `ctx.error(...)` or `ctx.reject(...)` |
35
- | `configure()` anywhere, the `clone` option | a config file imported before any Type is created; remove `clone` |
26
+ | ArkType 2 | ArkType 3 |
27
+ | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
28
+ | `out[0]`, `out.length`, `out.map(...)`, `for (const e of out)` | the same on `out.issues` |
29
+ | `error.message`, for text naming its path | `out.summary`, a line per error; `error.message` now leaves the path out |
30
+ | `error.problem`, `{ problem: "..." }` | `error.message`, `{ message: "..." }`, reworded as a whole sentence |
31
+ | `out.flatProblemsByPath`, `out.byPath`, `out.flatByPath` | `flatMessagesByPath(out)`, `byPath(out)`, `flatByPath(out)` from `arktype` |
32
+ | `out.message`, `out.toTraversalError()` | `out.summary`, `new TraversalError(out)` |
33
+ | `error.hasCode("min")`, `error.toString()` | `error.code === "min"`, `out.summary` (errors are plain objects; `error.message` has no path) |
34
+ | `ctx.errors.add(...)` | `ctx.error(...)` or `ctx.reject(...)` |
35
+ | `configure()` anywhere, the `clone` option | a config file imported before any Type is created; remove `clone` |
36
36
 
37
37
  Then update snapshots of error text: a message no longer says what the value was, like `(was a number)`. Replace adapters written for ArkType 2 as [Integrations](#integrations) says: they pass valid data and fail on the first invalid input.
38
38
 
@@ -43,9 +43,9 @@ A project whose bundler config uses `@ark/aot` (e.g. `precompile.vite()` from `@
43
43
  - Define Types from static values, and compose them inside definitions, like `const Admin = User.and({ role: "'admin'" })`. A definition reading a parameter, or a function calling `.or`, `.pick` or another composing method at runtime, fails the build. To reuse a pattern, define a Generic.
44
44
  - Define Types in JavaScript or TypeScript modules. A Svelte component's script isn't precompiled, so one importing arktype fails the build: put the Types, and any code checking a result against `type.errors`, in a `.ts` module the component imports.
45
45
  - If the project calls `configure()`, name its module as `config` under `precompile` in an `ark.json` beside `package.json`, which the plugin, the test drivers, the CLI and the ESLint rule all read.
46
- - A build error names the file, line and column, then why, then the fix on its last line. Apply that fix. Don't set `allowUnsafe` or switch to `runtime: "arktype"` to get past one. `npx arktype-precompile --check src` lists every one without bundling.
46
+ - A build error names the file, line and column, then why, then the fix on its last line. Apply that fix. Don't set `allowUnsafe` or switch to `runtime: "arktype"` to get past one. `npx @ark/aot --check src` (or `pnpm exec arktype-precompile --check src`) lists every one without bundling.
47
47
  - A validator's error messages say what failed but not what the value was, like `name must be a string`.
48
- - The build works out which introspection members, like a JSON Schema or `expression`, each validator needs from the code reading it, its dependencies' included, so the MCP SDK, the AI SDK and OpenAPI generators get one with nothing to set. Setting one under `members` only overrides that. Code the build can't see, like code outside the bundle reading an entry's export, throws naming the member to set true under `members`.
48
+ - The build works out which introspection members, like a JSON Schema or `expression`, each validator needs from the code reading it, its dependencies' included, so the MCP SDK, the AI SDK and OpenAPI generators get one with nothing to set. Setting one under `members` only overrides that. Code the build can't see, like code outside the bundle reading an entry's export, reads `undefined`, and warns in development naming the member to set true under `members`.
49
49
 
50
50
  Docs index: https://arktype.io/llms.txt, which links each page's Markdown. Any docs page is available as Markdown by adding `.md` to its URL, e.g. https://arktype.io/docs/objects.md. Every page in one file: https://arktype.io/llms-full.txt.
51
51
 
@@ -80,7 +80,7 @@ if (out instanceof type.errors) {
80
80
  ```
81
81
 
82
82
  - Calling a type returns the validated data or an `ArkErrors` instance. It does not throw, so check with `instanceof type.errors` rather than wrapping it in `try`/`catch`.
83
- - `ArkErrors` is not an array. Read individual errors from `out.issues`, e.g. `out.issues[0]` or `out.issues.map(e => e.message)`, each with a `path`, `code` and `message`. A `message` leaves out its path, like `must be an email address`.
83
+ - `ArkErrors` is not an array, though `for (const e of out)` iterates its errors. Read individual errors from `out.issues`, e.g. `out.issues[0]` or `out.issues.map(e => e.message)`, each with a `path`, `code` and `message`. A `message` leaves out its path, like `must be an email address`.
84
84
  - `User.assert(data)` throws a `TraversalError` instead, for places where invalid data is a bug. In a `catch`, check `e instanceof TraversalError` (from `arktype`) and read `e.arkErrors.issues`.
85
85
  - Name types in PascalCase (`User`). Name types that transform their input in camelCase (`parseUser`), since they behave like functions.
86
86
  - `typeof User.infer` is the output type. `typeof User.inferIn` is the input type, which differs once a type transforms its input or has defaults.
@@ -89,23 +89,23 @@ if (out instanceof type.errors) {
89
89
 
90
90
  Strings use TypeScript's operators. Write string literals in single quotes inside the definition. Object types don't go in strings: `"{ a: string }"` doesn't parse, so write objects as objects and name them in a scope to reuse them in a string.
91
91
 
92
- | Want | Write |
93
- | ----------------------- | ------------------------------------------------------------------------ |
94
- | optional key | `"key?": "string"` |
95
- | default (objects only) | `count: "number = 0"`, `plan: "'free' \| 'pro' = 'free'"` |
96
- | object or array default | `tags: "string[] = []"`, or a function: `Tags.default(() => [])` |
97
- | union | `"string \| number"`, `"'a' \| 'b'"` |
98
- | array | `"string[]"`, `"(string \| number)[]"` |
99
- | tuple | `["string", "number"]` |
100
- | number range | `"number > 0"`, `"0 <= number < 1"`, `"1 <= number.integer <= 100"` |
101
- | string or array length | `"string > 0"`, `"1 <= string <= 255"`, `"string[] >= 1"` |
102
- | divisibility | `"number % 2"` |
103
- | regex | `/^\d+$/` as a RegExp, or `"/^\\d+$/"` in a string |
104
- | record | `"Record<string, number>"` or `{ "[string]": "number" }` |
105
- | class instance | `"Date"`, `"Map"`, or `type.instanceOf(MyClass)` |
106
- | enum from values | `type.enumerated("a", "b")` or `type.valueOf(MyEnum)` |
107
- | array of a Type | `Item.array()`, `Item.array().atLeastLength(1)` |
108
- | custom error message | `type("string >= 8").configure({ message: "Use 8 or more characters" })` |
92
+ | Want | Write |
93
+ | ----------------------- | ------------------------------------------------------------------- |
94
+ | optional key | `"key?": "string"` |
95
+ | default (objects only) | `count: "number = 0"`, `plan: "'free' \| 'pro' = 'free'"` |
96
+ | object or array default | `tags: "string[] = []"`, or a function: `Tags.default(() => [])` |
97
+ | union | `"string \| number"`, `"'a' \| 'b'"` |
98
+ | array | `"string[]"`, `"(string \| number)[]"` |
99
+ | tuple | `["string", "number"]` |
100
+ | number range | `"number > 0"`, `"0 <= number < 1"`, `"1 <= number.integer <= 100"` |
101
+ | string or array length | `"string > 0"`, `"1 <= string <= 255"`, `"string[] >= 1"` |
102
+ | divisibility | `"number % 2"` |
103
+ | regex | `/^\d+$/` as a RegExp, or `"/^\\d+$/"` in a string |
104
+ | record | `"Record<string, number>"` or `{ "[string]": "number" }` |
105
+ | class instance | `"Date"`, `"Map"`, or `type.instanceOf(MyClass)` |
106
+ | enum from values | `type.enumerated("a", "b")` or `type.valueOf(MyEnum)` |
107
+ | array of a Type | `Item.array()`, `Item.array().atLeastLength(1)` |
108
+ | custom error message | `type.string.atLeastLength(8, "Use 8 or more characters")` |
109
109
 
110
110
  A regex with flags, like `/^a$/i`, must be a RegExp. Bounds bind tighter than `|`, so `"string <= 500 | null"` is a string of at most 500 characters, or null.
111
111
 
@@ -115,27 +115,27 @@ Common keywords: `string.email`, `string.uuid`, `string.url`, `string.ip`, `stri
115
115
 
116
116
  What a Zod schema becomes. To migrate a project, follow [references/migrating.md](references/migrating.md), which has every API, each library and the defaults that differ.
117
117
 
118
- | Zod | ArkType |
119
- | ----------------------------------------- | ------------------------------------------------------------------------ |
120
- | `z.object({ ... })` | `type({ ... })`, which keeps undeclared keys unless configured |
121
- | `z.string().min(1).max(100)` | `"1 <= string <= 100"` |
122
- | `z.string().email()`, `.url()`, `.uuid()` | `"string.email"`, `"string.url"`, `"string.uuid"` |
123
- | `z.number().int().positive()` | `"number.integer > 0"` |
124
- | `z.enum(["a", "b"])` | `"'a' \| 'b'"` |
125
- | `.optional()` on a key | `"key?": "T \| undefined"`, or `"key?": "T"` with Zod's defaults set |
126
- | `.nullable()` | `"T \| null"` |
127
- | `.default(x)` | `key: "T = x"` or `key: T.default(x)` |
128
- | `z.array(T).min(1)` | `T.array().atLeastLength(1)`, or `"string[] >= 1"` in a string |
129
- | `z.union([A, B])`, `z.discriminatedUnion` | `A.or(B)` |
130
- | `.extend({ ... })`, `.pick({ a: true })` | `.merge({ ... })`, `.pick("a")` |
131
- | `.refine(fn, message)` | `.narrow((v, ctx) => fn(v) \|\| ctx.reject({ message }))` |
132
- | `.refine(fn, { message, path })` | `ctx.reject({ message, relativePath: path })` |
133
- | `.min(1, "Name is required")` | `["string >= 1", "@", { message: "Name is required" }]` as a key's value |
134
- | `.transform(fn)` | `.pipe(fn)` |
135
- | `z.coerce.number()` | `type("unknown").pipe(Number).to("number")` |
136
- | `z.infer<typeof T>`, `z.input` | `typeof T.infer`, `typeof T.inferIn` |
137
- | `T.parse(x)`, `T.safeParse(x)` | `T.assert(x)`, `T(x)` checked with `instanceof type.errors` |
138
- | `e instanceof ZodError` in a `catch` | `e instanceof TraversalError`, then `e.arkErrors.issues` |
118
+ | Zod | ArkType |
119
+ | ----------------------------------------- | -------------------------------------------------------------------- |
120
+ | `z.object({ ... })` | `type({ ... })`, which keeps undeclared keys unless configured |
121
+ | `z.string().min(1).max(100)` | `"1 <= string <= 100"` |
122
+ | `z.string().email()`, `.url()`, `.uuid()` | `"string.email"`, `"string.url"`, `"string.uuid"` |
123
+ | `z.number().int().positive()` | `"number.integer > 0"` |
124
+ | `z.enum(["a", "b"])` | `"'a' \| 'b'"` |
125
+ | `.optional()` on a key | `"key?": "T \| undefined"`, or `"key?": "T"` with Zod's defaults set |
126
+ | `.nullable()` | `"T \| null"` |
127
+ | `.default(x)` | `key: "T = x"` or `key: T.default(x)` |
128
+ | `z.array(T).min(1)` | `T.array().atLeastLength(1)`, or `"string[] >= 1"` in a string |
129
+ | `z.union([A, B])`, `z.discriminatedUnion` | `A.or(B)` |
130
+ | `.extend({ ... })`, `.pick({ a: true })` | `.merge({ ... })`, `.pick("a")` |
131
+ | `.refine(fn, message)` | `.narrow((v, ctx) => fn(v) \|\| ctx.reject({ message }))` |
132
+ | `.refine(fn, { message, path })` | `ctx.reject({ message, relativePath: path })` |
133
+ | `.min(1, "Name is required")` | `type.string.atLeastLength(1, "Name is required")` |
134
+ | `.transform(fn)` | `.pipe(fn)` |
135
+ | `z.coerce.number()` | `type("unknown").pipe(Number).to("number")` |
136
+ | `z.infer<typeof T>`, `z.input` | `typeof T.infer`, `typeof T.inferIn` |
137
+ | `T.parse(x)`, `T.safeParse(x)` | `T.assert(x)`, `T(x)` checked with `instanceof type.errors` |
138
+ | `e instanceof ZodError` in a `catch` | `e instanceof TraversalError`, then `e.arkErrors.issues` |
139
139
 
140
140
  ## Composing types
141
141
 
@@ -159,8 +159,8 @@ const CustomerDraft = Customer.partial()
159
159
  Never interpolate a type into a string, as in ``type(`${Address}[]`)``. Use `Address.array()`, `Address.or(...)` and the other chained methods, or a tuple expression like `[Address, "[]"]`.
160
160
 
161
161
  - `.merge()` adds keys and replaces existing ones. `.and()` intersects, and throws when a key's types conflict.
162
- - `.merge()`, `"..."`, `.pick()`, `.omit()` and `.partial()` drop a `.narrow()` on the object they read, or throw if it also deletes undeclared keys. Keep the keys in a Type of their own, derive from that, and add each `.narrow()` last.
163
- - To share keys between types, merge a base Type, or `.pick()` them: `User.get("nick")` is the key's Type without its `?` or its default. To reuse a pattern across Types, define a Generic: `const Page = type("<t>", { items: "t[]", total: "number" })`, called as `Page(Item)`. In a Generic's body, `Omit`, `Pick`, `Partial`, `Required` and `Merge` do what the methods of those names do: `const Create = type("<t extends object>", "Omit<t, 'id'>")`.
162
+ - `.merge()`, `"..."`, `.pick()`, `.omit()` and `.partial()` drop a `.narrow()` on the object they read, or throw if the object also transforms its input: deletes undeclared keys, or has a default or a morph at a key. Keep the keys in a Type of their own, derive from that, and add each `.narrow()` last.
163
+ - To share keys between types, merge a base Type, or `.pick()` them: `User.get("nick")` is the key's Type without its `?` or its default, plus `| undefined` when the key is optional or defaulted. To reuse a pattern across Types, define a Generic: `const Page = type("<t>", { items: "t[]", total: "number" })`, called as `Page(Item)`. In a Generic's body, `Omit`, `Pick`, `Partial`, `Required` and `Merge` do what the methods of those names do: `const Create = type("<t extends object>", "Omit<t, 'id'>")`.
164
164
  - `.as<T>()` is a cast. To infer a narrower type, use `.narrow()` with a type predicate, e.g. `(s): s is \`data-${string}\` => s.startsWith("data-")`.
165
165
  - A definition built at runtime goes to `type.raw`, which infers nothing, then gets its type: `type.raw(Object.fromEntries(FLAGS.map(flag => [flag, "boolean"]))).as<Record<Flag, boolean>>()`.
166
166
 
@@ -242,31 +242,32 @@ const Signup = type({
242
242
  - Always reject with text. Returning `false` reads `must be valid according to an anonymous predicate`.
243
243
  - For several errors, call `ctx.error({ message, relativePath })` for each, then return `true`.
244
244
  - A narrow on an object runs only once every key is valid, so its error is never reported alongside a key's.
245
+ - A rule that depends on what the caller has, like a form's saved values, reads `ctx.context`. Declare its shape once on arktype's `ArkEnv` (`declare module "arktype" { interface ArkEnv { context(): { savedStreet?: string } } }`, in a file that imports or exports something) and validate with `T.withContext(context)`, a Standard Schema a form library takes as is. Don't create a Type for each value: one Type defined once can be precompiled. A narrow on literals can't read it, since ArkType checks them as the Type is defined.
245
246
  - A narrow can't give a literal its own text. ArkType calls it on each literal the Type allows, like `false`, `null`, `undefined` or `'a'`, when the Type is defined, and removes those it rejects, so `type("boolean").narrow((v, ctx) => v || ctx.reject({ message: "Accept the terms" }))` reads `must be true`. Write the values allowed, with the message: `type("true").configure({ message: "Accept the terms" })`.
246
247
 
247
248
  ## Error messages
248
249
 
249
250
  There are two ways to say what's wrong. Choose by the text you have:
250
251
 
251
- | The text is | Write it as | An issue's `message` | Its line of `out.summary` |
252
- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------- | ----------------------------- |
253
- | a whole sentence, like any Zod message: `"Enter a valid email"` | `message`, in `.configure({ message })`, a `"@"` tuple or `ctx.reject({ message })` | `Enter a valid email` | `email: Enter a valid email` |
254
- | what the value must be: `"a valid email"` | `.describe(text)`, `.configure({ expected: text })`, `ctx.reject(text)`, `ctx.mustBe(text)` | `must be a valid email` | `email must be a valid email` |
252
+ | The text is | Write it as | An issue's `message` | Its line of `out.summary` |
253
+ | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------- | ----------------------------- |
254
+ | a whole sentence, like any Zod message: `"Enter a valid email"` | `message`, as a constraint method's last argument, `.message(text)`, a `"@"` tuple or `ctx.reject({ message })` | `Enter a valid email` | `email: Enter a valid email` |
255
+ | what the value must be: `"a valid email"` | `.describe(text)`, `.configure({ expected: text })`, `ctx.mustBe(text)`, `ctx.error(text)` | `must be a valid email` | `email must be a valid email` |
255
256
 
256
- - A message from Zod, or any sentence a user reads, is always a `message`. Passed as a string to `ctx.reject()`, to `ctx.mustBe()`, to `.describe()`, as `expected` or as a string after `"@"`, it would read `must be Enter a valid email`.
257
+ - A message from Zod, or any sentence a user reads, is always a `message`. Passed to `ctx.mustBe()`, as a string to `ctx.error()`, to `.describe()`, as `expected` or as a string after `"@"`, it would read `must be Enter a valid email`. `ctx.reject()` takes no string, so TypeScript flags `ctx.reject("Enter a valid email")`: write `ctx.reject({ message: "Enter a valid email" })`.
257
258
  - An issue's `message` is what a form library, or anything else reading the Type through Standard Schema, shows beside the field. `out.summary`, and the `TraversalError` `.assert()` throws, write a line for each error with its path.
258
259
  - A `message` isn't composed into other text. What a Type is `expected` to be is: a union lists it, as in `must be a valid email or null`. So with `| null` or `| undefined`, configure the whole union, as in `["string.email | null", "@", { message }]`: a message on one branch is lost for a value of the wrong type. With `exactOptionalPropertyTypes: false`, an optional or defaulted key's value is such a union, so write `"role?": ["'admin' | 'user' | undefined", "@", { message }]`: a message on an enum, a literal or a boolean alone is never said there.
259
- - A `message` on `string.date.parse`, `string.url.parse` or `string.json.parse` isn't said for a string that fails to parse. Check, then convert: `type("string.date").pipe(s => new Date(s)).configure({ message })`.
260
+ - A `message` on `string.date.parse`, `string.url.parse` or `string.json.parse` isn't said for a string that fails to parse. Check, then convert: `type("string.date").pipe(s => new Date(s)).message(text)`.
260
261
 
261
- In a definition, a tuple with `"@"` configures a value where it's written, as Zod's `.min(1, "Name is required")` does. For a message per check, name the check after it, by its error code (`minLength`, `maxLength`, `pattern`, `min`, `max`, `divisor`), in the tuple or as `.configure()`'s second argument:
262
+ Pass a message as the last argument to a constraint method, like `atLeastLength`, `atMostLength`, `matching`, `atLeast`, `lessThan` or `divisibleBy`, and only that check says it, as with Zod's `.min(1, "Name is required")`. A check with no method, like a keyword's, takes its error code (`minLength`, `maxLength`, `pattern`, `min`, `max`, `divisor`) as `.message()`'s second argument. `.message(text)` alone sets the whole Type's message, as `.describe(text)` sets what it must be:
262
263
 
263
264
  ```ts
264
265
  const Invite = type({
265
- name: ["string > 0", "@", { message: "Name is required" }],
266
- email: ["string.email", "@", { message: "Enter a valid email" }],
267
- password: type("string >= 8 & /[0-9]/")
268
- .configure({ message: "Use 8 or more characters" }, "minLength")
269
- .configure({ message: "Include a number" }, "pattern")
266
+ name: type.string.atLeastLength(1, "Name is required"),
267
+ email: type("string.email").message("Enter a valid email", "pattern"),
268
+ password: type.string
269
+ .atLeastLength(8, "Use 8 or more characters")
270
+ .matching(/[0-9]/, "Include a number")
270
271
  })
271
272
 
272
273
  // name: Name is required
@@ -276,13 +277,11 @@ const Invite = type({
276
277
  const out = Invite({ name: "", email: "x", password: "short" })
277
278
  ```
278
279
 
279
- - A string `message` on a key's whole value, like `name`'s, is what the key says when its value is wrong, `undefined` included, and when the key is missing, so `Invite({})` reads the same for `name` and `email`. It covers Zod's `required_error`.
280
- - Configure a whole-value message last, after any `.pipe()` or `.to()`: `type("'on'").pipe(() => true).configure({ message: "Accept the terms" })`.
281
- - A message for one check leaves other errors with ArkType's text, like `password must be a string (was missing)`. To give those their own, name `"domain"` for a wrong type and `"self"` for a missing key.
282
- - A code names every check of that kind in the Type, nested keys' included, so configure a key's value, not the object around it. An array's length and its elements' are both `minLength`: configure the length on its own Type and intersect, as in `type("unknown[] >= 1").configure({ message: "Add one" }, "minLength").and(Tag.array())`.
283
- - Configure a whole-value message before per-check ones, since it replaces those configured earlier.
284
- - After a `.pipe()` or `.to()`, a code doesn't reach the Type the output is checked with, and a whole-value or `"self"` message on the transformed Type replaces the ones inside it. Configure that Type before passing it: `type("string.trim").to(type("string > 0").configure({ message: "Name is required" }))`.
285
- - Several failed checks report a pattern before a length. For an empty field to say `Email is required` first, as Zod's `.min(1, "...").email("...")` did, leave out the `>= 1` and choose by the value: `.configure({ message: e => (e.data === "" ? "Email is required" : "Enter a valid email") }, "pattern")`. For a length's message to come before a pattern's, write the pattern as a `.narrow()`, which runs once the length passes.
280
+ - A check's message leaves other errors with ArkType's text, like `name must be a string (was missing)`, as Zod's did. To give those their own, add `.message(text, "self")` for a missing key and `.message(text, "domain")` for a wrong type, after the constraints.
281
+ - A whole-value message, `.message(text)` or `["string", "@", { message }]` in a definition, is said for every failure, a wrong type and a missing key included, as Zod's `z.string({ error })` is. Configure it last, after any `.pipe()` or `.to()`, and never after checks' messages, which it replaces.
282
+ - A code names every check of that kind in the Type, nested keys' included. A message passed to a constraint method is that check's alone, so two patterns, or an array's length and its elements', keep their own: `Tag.array().atLeastLength(1, "Add a tag")`.
283
+ - After a `.pipe()` or `.to()`, a code doesn't reach the Type the output is checked with, and a whole-value or `"self"` message on the transformed Type replaces the ones inside it. Give that Type its messages before passing it: `type("string.trim").to(type.string.atLeastLength(1, "Name is required"))`.
284
+ - Several failed checks report a pattern before a length. For an empty field to say `Email is required` first, as Zod's `.min(1, "...").email("...")` did, leave out the `>= 1` and choose by the value: `.message(e => (e.data === "" ? "Email is required" : "Enter a valid email"), "pattern")`. For a length's message to come before a pattern's, write the pattern as a `.narrow()`, which runs once the length passes.
286
285
 
287
286
  To show each message beside its field, group `out.issues` by `issue.path.join(".")`, keeping the first `issue.message` for each key.
288
287
 
@@ -303,9 +302,9 @@ const types = scope({
303
302
  const post = types.Post({ title: "Hello", author: { name: "Ada" } })
304
303
  ```
305
304
 
306
- Don't wrap definitions inside a scope with `type()`. They're resolved within the scope, and `type()` would resolve them globally, so an alias there is `unresolvable`. For a `.narrow()` or a `.pipe()` inside a scope, write a tuple: `["Tag[]", ":", (tags, ctx) => ...]` or `["string", "=>", s => s.trim()]`. For JSON data, use the built-in `"string | number | boolean | null | object.json"` rather than a recursive type of your own.
305
+ Don't wrap definitions inside a scope with `type()`. They're resolved within the scope, and `type()` would resolve them globally, so an alias there is `unresolvable`. For a `.narrow()` or a `.pipe()` inside a scope, write a tuple: `["Tag[]", ":", (tags, ctx) => ...]` or `["string", "=>", s => s.trim()]`. For JSON data, use the built-in `"string | number | boolean | null | object.json"` rather than a recursive type of your own. Define recursive Types once, at module scope, since each stays in memory for the life of the process.
307
306
 
308
- TypeScript can't write an inferred cycle in a `.d.ts`: `tsc` declares it as `any`, or fails with `TS5088`. In a package or project whose declarations are emitted, write them with `npx arktype-precompile --declare` (from `@ark/aot`) instead, which names each cycle for its alias and changes nothing at runtime. See https://arktype.io/docs/precompile/advanced.md.
307
+ TypeScript can't write an inferred cycle in a `.d.ts`: `tsc` declares it as `any`, or fails with `TS5088`. In a package or project whose declarations are emitted, write them with `npx @ark/aot --declare` instead, which names each cycle for its alias and changes nothing at runtime. See https://arktype.io/docs/precompile/advanced.md.
309
308
 
310
309
  ## Extra keys
311
310
 
@@ -337,6 +336,7 @@ Where objects delete keys, don't `.narrow()` a union of them at an optional key
337
336
  - For a model's structured output or a tool, the AI SDK takes a Type as `schema` or `inputSchema`. The OpenAI SDK takes one through `standardResponseFormat` and `standardFunction` from `openai/helpers/standard-schema` (6.49 or later, every key required), and the Anthropic SDK through `betaStandardSchemaOutputFormat` and `betaStandardSchemaTool` from `@anthropic-ai/sdk/helpers/beta/standard-schema` (0.121 or later). LangChain's `tool()` type-checks with a Type but throws when the tool runs: give it `schema: T.toJsonSchema()` and call `T.assert(input)` inside.
338
337
  - Prefer a library's Standard Schema entry point (`standardSchemaResolver`, Hono's `sValidator` from `@hono/standard-validator`, Superforms' `standard()`) over an adapter written for ArkType 2 (`@hono/arktype-validator`, Superforms' `arktype()`, `arktypeResolver` before `@hookform/resolvers` 5), which fails on invalid input.
339
338
  - `User.toJsonSchema()` returns the equivalent JSON Schema. It throws for what JSON Schema can't express, like `Date`, `bigint`, a morph or a `.narrow()`. Handle those with a `fallback` keyed by the error's `code`, e.g. `{ fallback: { date: ctx => ({ ...ctx.base, type: "string", format: "date-time" }) } }`, or pass `{ fallback: annotatingFallback }` (exported from `arktype`) to write them as `x-arktype-*` keywords instead.
339
+ - `fromJsonSchema(schema)` from `arktype` reads a JSON Schema, or a Standard JSON Schema like a Zod schema (read as the JSON Schema it writes, so without its refinements or transforms), into a Type, inferring a literal JSON Schema's type. To compare schemas in any of those formats, like whether a new API schema still accepts what the old one did, read each with `fromJsonSchema` and use `.extends()`, `.equals()` or `.overlaps()`. Type methods take definitions, so pass a JSON Schema through `fromJsonSchema` first. See https://arktype.io/docs/json-schema/compare.md.
340
340
  - A model reads what a tool's parameter means from its JSON Schema `description`, which `.describe("the name of a city")` writes. The same text is what the field's errors say it must be. On a Type with checks, `.describe(text, "self")` leaves each check its own error, like `must be at most 7`.
341
341
  - Global configuration (error messages, `onUndeclaredKey`, `exactOptionalPropertyTypes`, `numberAllowsInfinity`, and so on) goes through `configure` from `arktype/config`, in its own file, imported first by every file that creates a Type. Calling `configure` after any Type is created, even by reading a keyword like `type.number`, throws unless it changes nothing. See https://arktype.io/docs/configuration.md.
342
342
 
@@ -371,25 +371,25 @@ check(User, { name: "Ada" }, { name: "", age: -1 })
371
371
 
372
372
  ## Errors and their fixes
373
373
 
374
- | Error | Fix |
375
- | --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
376
- | `'a' is unresolvable`, or `'int' is unresolvable. Did you mean 'number.integer'?` | use the name it suggests, or quote a string literal, `"'a'"`. Keywords have full names: `number.integer`, `string.email`, `Date` |
377
- | `Type definitions must be strings or objects (was Function)` | a class is `type.instanceOf(MyClass)` or a keyword like `"Date"`, and a predicate is `.narrow(fn)` |
378
- | `configure() has no option 'clone'` | remove an option 3.0 dropped, like `clone`, or use the name the error suggests for a misspelled one |
379
- | `problem was removed in 3.0; write message` | rename `problem` to `message` in `.configure()` and `ctx.reject()`, and write it as a whole sentence |
380
- | `'{' is unresolvable` | write an object as an object, not in a string |
381
- | `'Type' is unresolvable` | don't interpolate a Type into a string; use `Item.array()`, `Item.or(...)` or `[Item, "[]"]` |
382
- | `'^\d+$' is unresolvable`, or part of another regex, like `'^'` | put a regex in slashes, `"/^\\d+$/"` |
383
- | `Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple` | give the default in an object, `{ count: "number = 0" }` |
384
- | `Only required keys may specify default values` | drop the `?`: a key with a default may be missing |
385
- | `Argument of type 'never[]' is not assignable to parameter of type '() => ...'` at `.default([])` | an object or array default is a function, `.default(() => [])`, or `"string[] = []"` in a string |
386
- | `An unordered union of a type including a morph and a type with overlapping input is indeterminate` | narrow the morph's input so no other branch accepts it, as in `"string.numeric.parse \| undefined"`; for objects that delete keys, see [Extra keys](#extra-keys) |
387
- | `merge operand must be an object (was (In: { ... }) => To<...>)`, or `pick`, `omit`, `partial` | the object has a `.narrow()` and deletes undeclared keys: call the method on the object before its `.narrow()`, then add the narrow |
388
- | `Intersection at a of string and number results in an unsatisfiable type` | `.and()` found conflicting keys; use `.merge()` to replace them |
389
- | `Index keys "a", "b" should be specified as named props` | write `Record<"a" \| "b", T>` as `{ a: T, b: T }` |
390
- | `configure() must be called before any Type is created` | import the module calling `configure()` before any module that creates a Type |
391
- | `Must use import to load ES Module: .../arktype/out/index.js`, from Jest | arktype ships ES modules only: add `transformIgnorePatterns: ["/node_modules/(?!(\\.pnpm\|arktype\|arkregex\|arksets\|@ark)/)"]` and a transform that reads JavaScript, like the `ts-jest/presets/js-with-ts` preset |
392
- | an error message reading `must be Enter a valid email` | a sentence was passed as `expected`; pass it as `message` |
374
+ | Error | Fix |
375
+ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
376
+ | `'a' is unresolvable`, or `'int' is unresolvable. Did you mean 'number.integer'?` | use the name it suggests, or quote a string literal, `"'a'"`. Keywords have full names: `number.integer`, `string.email`, `Date` |
377
+ | `Type definitions must be strings or objects (was Function)` | a class is `type.instanceOf(MyClass)` or a keyword like `"Date"`, and a predicate is `.narrow(fn)` |
378
+ | `configure() has no option 'clone'` | remove an option 3.0 dropped, like `clone`, or use the name the error suggests for a misspelled one |
379
+ | `problem was removed in 3.0; write message` | rename `problem` to `message` in `.configure()` and `ctx.reject()`, and write it as a whole sentence |
380
+ | `'{' is unresolvable` | write an object as an object, not in a string |
381
+ | `'Type' is unresolvable` | don't interpolate a Type into a string; use `Item.array()`, `Item.or(...)` or `[Item, "[]"]` |
382
+ | `'^\d+$' is unresolvable`, or part of another regex, like `'^'` | put a regex in slashes, `"/^\\d+$/"` |
383
+ | `Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple` | give the default in an object, `{ count: "number = 0" }` |
384
+ | `Only required keys may specify default values` | drop the `?`: a key with a default may be missing |
385
+ | `Argument of type 'never[]' is not assignable to parameter of type '() => ...'` at `.default([])` | an object or array default is a function, `.default(() => [])`, or `"string[] = []"` in a string |
386
+ | `An unordered union of a type including a morph and a type with overlapping input is indeterminate` | narrow the morph's input so no other branch accepts it, as in `"string.numeric.parse \| undefined"`; for objects that delete keys, see [Extra keys](#extra-keys) |
387
+ | `merge operand must be an object (was (In: { ... }) => To<...>)`, or `pick`, `omit`, `partial` | the object has a `.narrow()` and deletes undeclared keys or has a default or morph at a key: call the method on the object before its `.narrow()`, then add the narrow |
388
+ | `Intersection at a of string and number results in an unsatisfiable type` | `.and()` found conflicting keys; use `.merge()` to replace them |
389
+ | `Index keys "a", "b" should be specified as named props` | write `Record<"a" \| "b", T>` as `{ a: T, b: T }` |
390
+ | `configure() must be called before any Type is created` | import the module calling `configure()` before any module that creates a Type |
391
+ | `Must use import to load ES Module: .../arktype/out/index.js`, from Jest | arktype ships ES modules only: add `transformIgnorePatterns: ["/node_modules/(?!(\\.pnpm\|arktype)/)"]` and a transform that reads JavaScript, like the `ts-jest/presets/js-with-ts` preset |
392
+ | an error message reading `must be Enter a valid email` | a sentence was passed as `expected`; pass it as `message` |
393
393
 
394
394
  ## Mistakes to avoid
395
395