@depup/sinclair__typebox 0.34.48-depup.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 (1072) hide show
  1. package/README.md +25 -0
  2. package/build/cjs/compiler/compiler.d.ts +55 -0
  3. package/build/cjs/compiler/compiler.js +670 -0
  4. package/build/cjs/compiler/index.d.ts +2 -0
  5. package/build/cjs/compiler/index.js +22 -0
  6. package/build/cjs/errors/errors.d.ts +91 -0
  7. package/build/cjs/errors/errors.js +599 -0
  8. package/build/cjs/errors/function.d.ts +21 -0
  9. package/build/cjs/errors/function.js +153 -0
  10. package/build/cjs/errors/index.d.ts +2 -0
  11. package/build/cjs/errors/index.js +19 -0
  12. package/build/cjs/index.d.ts +71 -0
  13. package/build/cjs/index.js +97 -0
  14. package/build/cjs/parser/index.d.ts +2 -0
  15. package/build/cjs/parser/index.js +39 -0
  16. package/build/cjs/parser/runtime/guard.d.ts +23 -0
  17. package/build/cjs/parser/runtime/guard.js +86 -0
  18. package/build/cjs/parser/runtime/index.d.ts +5 -0
  19. package/build/cjs/parser/runtime/index.js +45 -0
  20. package/build/cjs/parser/runtime/module.d.ts +9 -0
  21. package/build/cjs/parser/runtime/module.js +22 -0
  22. package/build/cjs/parser/runtime/parse.d.ts +9 -0
  23. package/build/cjs/parser/runtime/parse.js +160 -0
  24. package/build/cjs/parser/runtime/token.d.ts +8 -0
  25. package/build/cjs/parser/runtime/token.js +230 -0
  26. package/build/cjs/parser/runtime/types.d.ts +98 -0
  27. package/build/cjs/parser/runtime/types.js +71 -0
  28. package/build/cjs/parser/static/index.d.ts +3 -0
  29. package/build/cjs/parser/static/index.js +43 -0
  30. package/build/cjs/parser/static/parse.d.ts +20 -0
  31. package/build/cjs/parser/static/parse.js +3 -0
  32. package/build/cjs/parser/static/token.d.ts +108 -0
  33. package/build/cjs/parser/static/token.js +3 -0
  34. package/build/cjs/parser/static/types.d.ts +69 -0
  35. package/build/cjs/parser/static/types.js +3 -0
  36. package/build/cjs/syntax/index.d.ts +1 -0
  37. package/build/cjs/syntax/index.js +18 -0
  38. package/build/cjs/syntax/mapping.d.ts +167 -0
  39. package/build/cjs/syntax/mapping.js +491 -0
  40. package/build/cjs/syntax/parser.d.ts +162 -0
  41. package/build/cjs/syntax/parser.js +191 -0
  42. package/build/cjs/syntax/syntax.d.ts +12 -0
  43. package/build/cjs/syntax/syntax.js +54 -0
  44. package/build/cjs/system/index.d.ts +2 -0
  45. package/build/cjs/system/index.js +19 -0
  46. package/build/cjs/system/policy.d.ts +29 -0
  47. package/build/cjs/system/policy.js +58 -0
  48. package/build/cjs/system/system.d.ts +16 -0
  49. package/build/cjs/system/system.js +43 -0
  50. package/build/cjs/type/any/any.d.ts +8 -0
  51. package/build/cjs/type/any/any.js +10 -0
  52. package/build/cjs/type/any/index.d.ts +1 -0
  53. package/build/cjs/type/any/index.js +18 -0
  54. package/build/cjs/type/argument/argument.d.ts +9 -0
  55. package/build/cjs/type/argument/argument.js +10 -0
  56. package/build/cjs/type/argument/index.d.ts +1 -0
  57. package/build/cjs/type/argument/index.js +18 -0
  58. package/build/cjs/type/array/array.d.ts +28 -0
  59. package/build/cjs/type/array/array.js +10 -0
  60. package/build/cjs/type/array/index.d.ts +1 -0
  61. package/build/cjs/type/array/index.js +18 -0
  62. package/build/cjs/type/async-iterator/async-iterator.d.ts +11 -0
  63. package/build/cjs/type/async-iterator/async-iterator.js +10 -0
  64. package/build/cjs/type/async-iterator/index.d.ts +1 -0
  65. package/build/cjs/type/async-iterator/index.js +18 -0
  66. package/build/cjs/type/awaited/awaited.d.ts +14 -0
  67. package/build/cjs/type/awaited/awaited.js +41 -0
  68. package/build/cjs/type/awaited/index.d.ts +1 -0
  69. package/build/cjs/type/awaited/index.js +18 -0
  70. package/build/cjs/type/bigint/bigint.d.ts +16 -0
  71. package/build/cjs/type/bigint/bigint.js +10 -0
  72. package/build/cjs/type/bigint/index.d.ts +1 -0
  73. package/build/cjs/type/bigint/index.js +18 -0
  74. package/build/cjs/type/boolean/boolean.d.ts +9 -0
  75. package/build/cjs/type/boolean/boolean.js +10 -0
  76. package/build/cjs/type/boolean/index.d.ts +1 -0
  77. package/build/cjs/type/boolean/index.js +18 -0
  78. package/build/cjs/type/clone/index.d.ts +2 -0
  79. package/build/cjs/type/clone/index.js +19 -0
  80. package/build/cjs/type/clone/type.d.ts +5 -0
  81. package/build/cjs/type/clone/type.js +14 -0
  82. package/build/cjs/type/clone/value.d.ts +2 -0
  83. package/build/cjs/type/clone/value.js +73 -0
  84. package/build/cjs/type/composite/composite.d.ts +18 -0
  85. package/build/cjs/type/composite/composite.js +46 -0
  86. package/build/cjs/type/composite/index.d.ts +1 -0
  87. package/build/cjs/type/composite/index.js +18 -0
  88. package/build/cjs/type/computed/computed.d.ts +9 -0
  89. package/build/cjs/type/computed/computed.js +10 -0
  90. package/build/cjs/type/computed/index.d.ts +1 -0
  91. package/build/cjs/type/computed/index.js +18 -0
  92. package/build/cjs/type/const/const.d.ts +27 -0
  93. package/build/cjs/type/const/const.js +58 -0
  94. package/build/cjs/type/const/index.d.ts +1 -0
  95. package/build/cjs/type/const/index.js +18 -0
  96. package/build/cjs/type/constructor/constructor.d.ts +23 -0
  97. package/build/cjs/type/constructor/constructor.js +10 -0
  98. package/build/cjs/type/constructor/index.d.ts +1 -0
  99. package/build/cjs/type/constructor/index.js +18 -0
  100. package/build/cjs/type/constructor-parameters/constructor-parameters.d.ts +7 -0
  101. package/build/cjs/type/constructor-parameters/constructor-parameters.js +44 -0
  102. package/build/cjs/type/constructor-parameters/index.d.ts +1 -0
  103. package/build/cjs/type/constructor-parameters/index.js +18 -0
  104. package/build/cjs/type/create/immutable.d.ts +2 -0
  105. package/build/cjs/type/create/immutable.js +70 -0
  106. package/build/cjs/type/create/index.d.ts +1 -0
  107. package/build/cjs/type/create/index.js +18 -0
  108. package/build/cjs/type/create/type.d.ts +3 -0
  109. package/build/cjs/type/create/type.js +19 -0
  110. package/build/cjs/type/date/date.d.ts +21 -0
  111. package/build/cjs/type/date/date.js +10 -0
  112. package/build/cjs/type/date/index.d.ts +1 -0
  113. package/build/cjs/type/date/index.js +18 -0
  114. package/build/cjs/type/discard/discard.d.ts +2 -0
  115. package/build/cjs/type/discard/discard.js +12 -0
  116. package/build/cjs/type/discard/index.d.ts +1 -0
  117. package/build/cjs/type/discard/index.js +18 -0
  118. package/build/cjs/type/enum/enum.d.ts +14 -0
  119. package/build/cjs/type/enum/enum.js +22 -0
  120. package/build/cjs/type/enum/index.d.ts +1 -0
  121. package/build/cjs/type/enum/index.js +18 -0
  122. package/build/cjs/type/error/error.d.ts +4 -0
  123. package/build/cjs/type/error/error.js +11 -0
  124. package/build/cjs/type/error/index.d.ts +1 -0
  125. package/build/cjs/type/error/index.js +18 -0
  126. package/build/cjs/type/exclude/exclude-from-mapped-result.d.ts +11 -0
  127. package/build/cjs/type/exclude/exclude-from-mapped-result.js +22 -0
  128. package/build/cjs/type/exclude/exclude-from-template-literal.d.ts +5 -0
  129. package/build/cjs/type/exclude/exclude-from-template-literal.js +9 -0
  130. package/build/cjs/type/exclude/exclude.d.ts +21 -0
  131. package/build/cjs/type/exclude/exclude.js +29 -0
  132. package/build/cjs/type/exclude/index.d.ts +3 -0
  133. package/build/cjs/type/exclude/index.js +20 -0
  134. package/build/cjs/type/extends/extends-check.d.ts +10 -0
  135. package/build/cjs/type/extends/extends-check.js +641 -0
  136. package/build/cjs/type/extends/extends-from-mapped-key.d.ts +14 -0
  137. package/build/cjs/type/extends/extends-from-mapped-key.js +29 -0
  138. package/build/cjs/type/extends/extends-from-mapped-result.d.ts +11 -0
  139. package/build/cjs/type/extends/extends-from-mapped-result.js +23 -0
  140. package/build/cjs/type/extends/extends-undefined.d.ts +3 -0
  141. package/build/cjs/type/extends/extends-undefined.js +24 -0
  142. package/build/cjs/type/extends/extends.d.ts +16 -0
  143. package/build/cjs/type/extends/extends.js +27 -0
  144. package/build/cjs/type/extends/index.d.ts +5 -0
  145. package/build/cjs/type/extends/index.js +22 -0
  146. package/build/cjs/type/extract/extract-from-mapped-result.d.ts +11 -0
  147. package/build/cjs/type/extract/extract-from-mapped-result.js +22 -0
  148. package/build/cjs/type/extract/extract-from-template-literal.d.ts +5 -0
  149. package/build/cjs/type/extract/extract-from-template-literal.js +9 -0
  150. package/build/cjs/type/extract/extract.d.ts +21 -0
  151. package/build/cjs/type/extract/extract.js +29 -0
  152. package/build/cjs/type/extract/index.d.ts +3 -0
  153. package/build/cjs/type/extract/index.js +20 -0
  154. package/build/cjs/type/function/function.d.ts +23 -0
  155. package/build/cjs/type/function/function.js +10 -0
  156. package/build/cjs/type/function/index.d.ts +1 -0
  157. package/build/cjs/type/function/index.js +18 -0
  158. package/build/cjs/type/guard/index.d.ts +3 -0
  159. package/build/cjs/type/guard/index.js +40 -0
  160. package/build/cjs/type/guard/kind.d.ts +147 -0
  161. package/build/cjs/type/guard/kind.js +320 -0
  162. package/build/cjs/type/guard/type.d.ts +152 -0
  163. package/build/cjs/type/guard/type.js +597 -0
  164. package/build/cjs/type/guard/value.d.ts +34 -0
  165. package/build/cjs/type/guard/value.js +89 -0
  166. package/build/cjs/type/helpers/helpers.d.ts +42 -0
  167. package/build/cjs/type/helpers/helpers.js +8 -0
  168. package/build/cjs/type/helpers/index.d.ts +1 -0
  169. package/build/cjs/type/helpers/index.js +18 -0
  170. package/build/cjs/type/index.d.ts +71 -0
  171. package/build/cjs/type/index.js +88 -0
  172. package/build/cjs/type/indexed/index.d.ts +4 -0
  173. package/build/cjs/type/indexed/index.js +21 -0
  174. package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +13 -0
  175. package/build/cjs/type/indexed/indexed-from-mapped-key.js +26 -0
  176. package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +12 -0
  177. package/build/cjs/type/indexed/indexed-from-mapped-result.js +24 -0
  178. package/build/cjs/type/indexed/indexed-property-keys.d.ts +14 -0
  179. package/build/cjs/type/indexed/indexed-property-keys.js +36 -0
  180. package/build/cjs/type/indexed/indexed.d.ts +52 -0
  181. package/build/cjs/type/indexed/indexed.js +98 -0
  182. package/build/cjs/type/instance-type/index.d.ts +1 -0
  183. package/build/cjs/type/instance-type/index.js +18 -0
  184. package/build/cjs/type/instance-type/instance-type.d.ts +6 -0
  185. package/build/cjs/type/instance-type/instance-type.js +44 -0
  186. package/build/cjs/type/instantiate/index.d.ts +1 -0
  187. package/build/cjs/type/instantiate/index.js +18 -0
  188. package/build/cjs/type/instantiate/instantiate.d.ts +50 -0
  189. package/build/cjs/type/instantiate/instantiate.js +153 -0
  190. package/build/cjs/type/integer/index.d.ts +1 -0
  191. package/build/cjs/type/integer/index.js +18 -0
  192. package/build/cjs/type/integer/integer.d.ts +16 -0
  193. package/build/cjs/type/integer/integer.js +10 -0
  194. package/build/cjs/type/intersect/index.d.ts +3 -0
  195. package/build/cjs/type/intersect/index.js +20 -0
  196. package/build/cjs/type/intersect/intersect-create.d.ts +3 -0
  197. package/build/cjs/type/intersect/intersect-create.js +23 -0
  198. package/build/cjs/type/intersect/intersect-evaluated.d.ts +13 -0
  199. package/build/cjs/type/intersect/intersect-evaluated.js +42 -0
  200. package/build/cjs/type/intersect/intersect-type.d.ts +15 -0
  201. package/build/cjs/type/intersect/intersect-type.js +4 -0
  202. package/build/cjs/type/intersect/intersect.d.ts +6 -0
  203. package/build/cjs/type/intersect/intersect.js +21 -0
  204. package/build/cjs/type/intrinsic/capitalize.d.ts +5 -0
  205. package/build/cjs/type/intrinsic/capitalize.js +9 -0
  206. package/build/cjs/type/intrinsic/index.d.ts +6 -0
  207. package/build/cjs/type/intrinsic/index.js +23 -0
  208. package/build/cjs/type/intrinsic/intrinsic-from-mapped-key.d.ts +14 -0
  209. package/build/cjs/type/intrinsic/intrinsic-from-mapped-key.js +30 -0
  210. package/build/cjs/type/intrinsic/intrinsic.d.ts +16 -0
  211. package/build/cjs/type/intrinsic/intrinsic.js +68 -0
  212. package/build/cjs/type/intrinsic/lowercase.d.ts +5 -0
  213. package/build/cjs/type/intrinsic/lowercase.js +9 -0
  214. package/build/cjs/type/intrinsic/uncapitalize.d.ts +5 -0
  215. package/build/cjs/type/intrinsic/uncapitalize.js +9 -0
  216. package/build/cjs/type/intrinsic/uppercase.d.ts +5 -0
  217. package/build/cjs/type/intrinsic/uppercase.js +9 -0
  218. package/build/cjs/type/iterator/index.d.ts +1 -0
  219. package/build/cjs/type/iterator/index.js +18 -0
  220. package/build/cjs/type/iterator/iterator.d.ts +11 -0
  221. package/build/cjs/type/iterator/iterator.js +10 -0
  222. package/build/cjs/type/keyof/index.d.ts +4 -0
  223. package/build/cjs/type/keyof/index.js +21 -0
  224. package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +12 -0
  225. package/build/cjs/type/keyof/keyof-from-mapped-result.js +23 -0
  226. package/build/cjs/type/keyof/keyof-property-entries.d.ts +7 -0
  227. package/build/cjs/type/keyof/keyof-property-entries.js +16 -0
  228. package/build/cjs/type/keyof/keyof-property-keys.d.ts +24 -0
  229. package/build/cjs/type/keyof/keyof-property-keys.js +78 -0
  230. package/build/cjs/type/keyof/keyof.d.ts +21 -0
  231. package/build/cjs/type/keyof/keyof.js +40 -0
  232. package/build/cjs/type/literal/index.d.ts +1 -0
  233. package/build/cjs/type/literal/index.js +18 -0
  234. package/build/cjs/type/literal/literal.d.ts +10 -0
  235. package/build/cjs/type/literal/literal.js +14 -0
  236. package/build/cjs/type/mapped/index.d.ts +3 -0
  237. package/build/cjs/type/mapped/index.js +20 -0
  238. package/build/cjs/type/mapped/mapped-key.d.ts +8 -0
  239. package/build/cjs/type/mapped/mapped-key.js +13 -0
  240. package/build/cjs/type/mapped/mapped-result.d.ts +9 -0
  241. package/build/cjs/type/mapped/mapped-result.js +13 -0
  242. package/build/cjs/type/mapped/mapped.d.ts +47 -0
  243. package/build/cjs/type/mapped/mapped.js +107 -0
  244. package/build/cjs/type/module/compute.d.ts +59 -0
  245. package/build/cjs/type/module/compute.js +205 -0
  246. package/build/cjs/type/module/index.d.ts +1 -0
  247. package/build/cjs/type/module/index.js +18 -0
  248. package/build/cjs/type/module/infer.d.ts +49 -0
  249. package/build/cjs/type/module/infer.js +3 -0
  250. package/build/cjs/type/module/module.d.ts +27 -0
  251. package/build/cjs/type/module/module.js +38 -0
  252. package/build/cjs/type/never/index.d.ts +1 -0
  253. package/build/cjs/type/never/index.js +18 -0
  254. package/build/cjs/type/never/never.d.ts +9 -0
  255. package/build/cjs/type/never/never.js +10 -0
  256. package/build/cjs/type/not/index.d.ts +1 -0
  257. package/build/cjs/type/not/index.js +18 -0
  258. package/build/cjs/type/not/not.d.ts +10 -0
  259. package/build/cjs/type/not/not.js +10 -0
  260. package/build/cjs/type/null/index.d.ts +1 -0
  261. package/build/cjs/type/null/index.js +18 -0
  262. package/build/cjs/type/null/null.d.ts +9 -0
  263. package/build/cjs/type/null/null.js +10 -0
  264. package/build/cjs/type/number/index.d.ts +1 -0
  265. package/build/cjs/type/number/index.js +18 -0
  266. package/build/cjs/type/number/number.d.ts +16 -0
  267. package/build/cjs/type/number/number.js +10 -0
  268. package/build/cjs/type/object/index.d.ts +1 -0
  269. package/build/cjs/type/object/index.js +18 -0
  270. package/build/cjs/type/object/object.d.ts +51 -0
  271. package/build/cjs/type/object/object.js +22 -0
  272. package/build/cjs/type/omit/index.d.ts +3 -0
  273. package/build/cjs/type/omit/index.js +20 -0
  274. package/build/cjs/type/omit/omit-from-mapped-key.d.ts +12 -0
  275. package/build/cjs/type/omit/omit-from-mapped-key.js +26 -0
  276. package/build/cjs/type/omit/omit-from-mapped-result.d.ts +12 -0
  277. package/build/cjs/type/omit/omit-from-mapped-result.js +23 -0
  278. package/build/cjs/type/omit/omit.d.ts +36 -0
  279. package/build/cjs/type/omit/omit.js +75 -0
  280. package/build/cjs/type/optional/index.d.ts +2 -0
  281. package/build/cjs/type/optional/index.js +19 -0
  282. package/build/cjs/type/optional/optional-from-mapped-result.d.ts +10 -0
  283. package/build/cjs/type/optional/optional-from-mapped-result.js +22 -0
  284. package/build/cjs/type/optional/optional.d.ts +20 -0
  285. package/build/cjs/type/optional/optional.js +26 -0
  286. package/build/cjs/type/parameters/index.d.ts +1 -0
  287. package/build/cjs/type/parameters/index.js +18 -0
  288. package/build/cjs/type/parameters/parameters.d.ts +7 -0
  289. package/build/cjs/type/parameters/parameters.js +44 -0
  290. package/build/cjs/type/partial/index.d.ts +2 -0
  291. package/build/cjs/type/partial/index.js +19 -0
  292. package/build/cjs/type/partial/partial-from-mapped-result.d.ts +12 -0
  293. package/build/cjs/type/partial/partial-from-mapped-result.js +23 -0
  294. package/build/cjs/type/partial/partial.d.ts +35 -0
  295. package/build/cjs/type/partial/partial.js +111 -0
  296. package/build/cjs/type/patterns/index.d.ts +1 -0
  297. package/build/cjs/type/patterns/index.js +18 -0
  298. package/build/cjs/type/patterns/patterns.d.ts +8 -0
  299. package/build/cjs/type/patterns/patterns.js +12 -0
  300. package/build/cjs/type/pick/index.d.ts +3 -0
  301. package/build/cjs/type/pick/index.js +20 -0
  302. package/build/cjs/type/pick/pick-from-mapped-key.d.ts +12 -0
  303. package/build/cjs/type/pick/pick-from-mapped-key.js +28 -0
  304. package/build/cjs/type/pick/pick-from-mapped-result.d.ts +12 -0
  305. package/build/cjs/type/pick/pick-from-mapped-result.js +23 -0
  306. package/build/cjs/type/pick/pick.d.ts +36 -0
  307. package/build/cjs/type/pick/pick.js +70 -0
  308. package/build/cjs/type/promise/index.d.ts +1 -0
  309. package/build/cjs/type/promise/index.js +18 -0
  310. package/build/cjs/type/promise/promise.d.ts +11 -0
  311. package/build/cjs/type/promise/promise.js +10 -0
  312. package/build/cjs/type/readonly/index.d.ts +2 -0
  313. package/build/cjs/type/readonly/index.js +19 -0
  314. package/build/cjs/type/readonly/readonly-from-mapped-result.d.ts +10 -0
  315. package/build/cjs/type/readonly/readonly-from-mapped-result.js +22 -0
  316. package/build/cjs/type/readonly/readonly.d.ts +20 -0
  317. package/build/cjs/type/readonly/readonly.js +26 -0
  318. package/build/cjs/type/readonly-optional/index.d.ts +1 -0
  319. package/build/cjs/type/readonly-optional/index.js +18 -0
  320. package/build/cjs/type/readonly-optional/readonly-optional.d.ts +6 -0
  321. package/build/cjs/type/readonly-optional/readonly-optional.js +10 -0
  322. package/build/cjs/type/record/index.d.ts +1 -0
  323. package/build/cjs/type/record/index.js +18 -0
  324. package/build/cjs/type/record/record.d.ts +71 -0
  325. package/build/cjs/type/record/record.js +123 -0
  326. package/build/cjs/type/recursive/index.d.ts +1 -0
  327. package/build/cjs/type/recursive/index.js +18 -0
  328. package/build/cjs/type/recursive/recursive.d.ts +16 -0
  329. package/build/cjs/type/recursive/recursive.js +19 -0
  330. package/build/cjs/type/ref/index.d.ts +1 -0
  331. package/build/cjs/type/ref/index.js +18 -0
  332. package/build/cjs/type/ref/ref.d.ts +41 -0
  333. package/build/cjs/type/ref/ref.js +14 -0
  334. package/build/cjs/type/regexp/index.d.ts +1 -0
  335. package/build/cjs/type/regexp/index.js +18 -0
  336. package/build/cjs/type/regexp/regexp.d.ts +20 -0
  337. package/build/cjs/type/regexp/regexp.js +12 -0
  338. package/build/cjs/type/registry/format.d.ts +13 -0
  339. package/build/cjs/type/registry/format.js +35 -0
  340. package/build/cjs/type/registry/index.d.ts +2 -0
  341. package/build/cjs/type/registry/index.js +39 -0
  342. package/build/cjs/type/registry/type.d.ts +13 -0
  343. package/build/cjs/type/registry/type.js +35 -0
  344. package/build/cjs/type/required/index.d.ts +2 -0
  345. package/build/cjs/type/required/index.js +19 -0
  346. package/build/cjs/type/required/required-from-mapped-result.d.ts +12 -0
  347. package/build/cjs/type/required/required-from-mapped-result.js +22 -0
  348. package/build/cjs/type/required/required.d.ts +35 -0
  349. package/build/cjs/type/required/required.js +110 -0
  350. package/build/cjs/type/rest/index.d.ts +1 -0
  351. package/build/cjs/type/rest/index.js +18 -0
  352. package/build/cjs/type/rest/rest.d.ts +10 -0
  353. package/build/cjs/type/rest/rest.js +19 -0
  354. package/build/cjs/type/return-type/index.d.ts +1 -0
  355. package/build/cjs/type/return-type/index.js +18 -0
  356. package/build/cjs/type/return-type/return-type.d.ts +6 -0
  357. package/build/cjs/type/return-type/return-type.js +44 -0
  358. package/build/cjs/type/schema/anyschema.d.ts +33 -0
  359. package/build/cjs/type/schema/anyschema.js +3 -0
  360. package/build/cjs/type/schema/index.d.ts +2 -0
  361. package/build/cjs/type/schema/index.js +19 -0
  362. package/build/cjs/type/schema/schema.d.ts +29 -0
  363. package/build/cjs/type/schema/schema.js +4 -0
  364. package/build/cjs/type/sets/index.d.ts +1 -0
  365. package/build/cjs/type/sets/index.js +18 -0
  366. package/build/cjs/type/sets/set.d.ts +28 -0
  367. package/build/cjs/type/sets/set.js +59 -0
  368. package/build/cjs/type/static/index.d.ts +1 -0
  369. package/build/cjs/type/static/index.js +18 -0
  370. package/build/cjs/type/static/static.d.ts +39 -0
  371. package/build/cjs/type/static/static.js +3 -0
  372. package/build/cjs/type/string/index.d.ts +1 -0
  373. package/build/cjs/type/string/index.js +18 -0
  374. package/build/cjs/type/string/string.d.ts +25 -0
  375. package/build/cjs/type/string/string.js +10 -0
  376. package/build/cjs/type/symbol/index.d.ts +1 -0
  377. package/build/cjs/type/symbol/index.js +18 -0
  378. package/build/cjs/type/symbol/symbol.d.ts +10 -0
  379. package/build/cjs/type/symbol/symbol.js +10 -0
  380. package/build/cjs/type/symbols/index.d.ts +1 -0
  381. package/build/cjs/type/symbols/index.js +18 -0
  382. package/build/cjs/type/symbols/symbols.d.ts +10 -0
  383. package/build/cjs/type/symbols/symbols.js +14 -0
  384. package/build/cjs/type/template-literal/finite.d.ts +19 -0
  385. package/build/cjs/type/template-literal/finite.js +56 -0
  386. package/build/cjs/type/template-literal/generate.d.ts +21 -0
  387. package/build/cjs/type/template-literal/generate.js +60 -0
  388. package/build/cjs/type/template-literal/index.d.ts +7 -0
  389. package/build/cjs/type/template-literal/index.js +24 -0
  390. package/build/cjs/type/template-literal/parse.d.ts +20 -0
  391. package/build/cjs/type/template-literal/parse.js +174 -0
  392. package/build/cjs/type/template-literal/pattern.d.ts +5 -0
  393. package/build/cjs/type/template-literal/pattern.js +39 -0
  394. package/build/cjs/type/template-literal/syntax.d.ts +20 -0
  395. package/build/cjs/type/template-literal/syntax.js +59 -0
  396. package/build/cjs/type/template-literal/template-literal.d.ts +30 -0
  397. package/build/cjs/type/template-literal/template-literal.js +17 -0
  398. package/build/cjs/type/template-literal/union.d.ts +9 -0
  399. package/build/cjs/type/template-literal/union.js +13 -0
  400. package/build/cjs/type/transform/index.d.ts +1 -0
  401. package/build/cjs/type/transform/index.js +18 -0
  402. package/build/cjs/type/transform/transform.d.ts +30 -0
  403. package/build/cjs/type/transform/transform.js +47 -0
  404. package/build/cjs/type/tuple/index.d.ts +1 -0
  405. package/build/cjs/type/tuple/index.js +18 -0
  406. package/build/cjs/type/tuple/tuple.d.ts +16 -0
  407. package/build/cjs/type/tuple/tuple.js +13 -0
  408. package/build/cjs/type/type/index.d.ts +6 -0
  409. package/build/cjs/type/type/index.js +51 -0
  410. package/build/cjs/type/type/javascript.d.ts +64 -0
  411. package/build/cjs/type/type/javascript.js +104 -0
  412. package/build/cjs/type/type/json.d.ts +208 -0
  413. package/build/cjs/type/type/json.js +226 -0
  414. package/build/cjs/type/type/type.d.ts +59 -0
  415. package/build/cjs/type/type/type.js +129 -0
  416. package/build/cjs/type/uint8array/index.d.ts +1 -0
  417. package/build/cjs/type/uint8array/index.js +18 -0
  418. package/build/cjs/type/uint8array/uint8array.d.ts +13 -0
  419. package/build/cjs/type/uint8array/uint8array.js +10 -0
  420. package/build/cjs/type/undefined/index.d.ts +1 -0
  421. package/build/cjs/type/undefined/index.js +18 -0
  422. package/build/cjs/type/undefined/undefined.d.ts +9 -0
  423. package/build/cjs/type/undefined/undefined.js +10 -0
  424. package/build/cjs/type/union/index.d.ts +3 -0
  425. package/build/cjs/type/union/index.js +20 -0
  426. package/build/cjs/type/union/union-create.d.ts +3 -0
  427. package/build/cjs/type/union/union-create.js +9 -0
  428. package/build/cjs/type/union/union-evaluated.d.ts +13 -0
  429. package/build/cjs/type/union/union-evaluated.js +40 -0
  430. package/build/cjs/type/union/union-type.d.ts +12 -0
  431. package/build/cjs/type/union/union-type.js +4 -0
  432. package/build/cjs/type/union/union.d.ts +6 -0
  433. package/build/cjs/type/union/union.js +14 -0
  434. package/build/cjs/type/unknown/index.d.ts +1 -0
  435. package/build/cjs/type/unknown/index.js +18 -0
  436. package/build/cjs/type/unknown/unknown.d.ts +8 -0
  437. package/build/cjs/type/unknown/unknown.js +10 -0
  438. package/build/cjs/type/unsafe/index.d.ts +1 -0
  439. package/build/cjs/type/unsafe/index.js +18 -0
  440. package/build/cjs/type/unsafe/unsafe.d.ts +11 -0
  441. package/build/cjs/type/unsafe/unsafe.js +10 -0
  442. package/build/cjs/type/void/index.d.ts +1 -0
  443. package/build/cjs/type/void/index.js +18 -0
  444. package/build/cjs/type/void/void.d.ts +9 -0
  445. package/build/cjs/type/void/void.js +10 -0
  446. package/build/cjs/value/assert/assert.d.ts +15 -0
  447. package/build/cjs/value/assert/assert.js +55 -0
  448. package/build/cjs/value/assert/index.d.ts +1 -0
  449. package/build/cjs/value/assert/index.js +18 -0
  450. package/build/cjs/value/cast/cast.d.ts +11 -0
  451. package/build/cjs/value/cast/cast.js +241 -0
  452. package/build/cjs/value/cast/index.d.ts +1 -0
  453. package/build/cjs/value/cast/index.js +18 -0
  454. package/build/cjs/value/check/check.d.ts +11 -0
  455. package/build/cjs/value/check/check.js +476 -0
  456. package/build/cjs/value/check/index.d.ts +1 -0
  457. package/build/cjs/value/check/index.js +18 -0
  458. package/build/cjs/value/clean/clean.d.ts +5 -0
  459. package/build/cjs/value/clean/clean.js +149 -0
  460. package/build/cjs/value/clean/index.d.ts +1 -0
  461. package/build/cjs/value/clean/index.js +18 -0
  462. package/build/cjs/value/clone/clone.d.ts +2 -0
  463. package/build/cjs/value/clone/clone.js +60 -0
  464. package/build/cjs/value/clone/index.d.ts +1 -0
  465. package/build/cjs/value/clone/index.js +18 -0
  466. package/build/cjs/value/convert/convert.d.ts +5 -0
  467. package/build/cjs/value/convert/convert.js +264 -0
  468. package/build/cjs/value/convert/index.d.ts +1 -0
  469. package/build/cjs/value/convert/index.js +18 -0
  470. package/build/cjs/value/create/create.d.ts +11 -0
  471. package/build/cjs/value/create/create.js +474 -0
  472. package/build/cjs/value/create/index.d.ts +1 -0
  473. package/build/cjs/value/create/index.js +18 -0
  474. package/build/cjs/value/decode/decode.d.ts +6 -0
  475. package/build/cjs/value/decode/decode.js +14 -0
  476. package/build/cjs/value/decode/index.d.ts +1 -0
  477. package/build/cjs/value/decode/index.js +18 -0
  478. package/build/cjs/value/default/default.d.ts +5 -0
  479. package/build/cjs/value/default/default.js +176 -0
  480. package/build/cjs/value/default/index.d.ts +1 -0
  481. package/build/cjs/value/default/index.js +18 -0
  482. package/build/cjs/value/delta/delta.d.ts +32 -0
  483. package/build/cjs/value/delta/delta.js +178 -0
  484. package/build/cjs/value/delta/index.d.ts +1 -0
  485. package/build/cjs/value/delta/index.js +18 -0
  486. package/build/cjs/value/deref/deref.d.ts +12 -0
  487. package/build/cjs/value/deref/deref.js +36 -0
  488. package/build/cjs/value/deref/index.d.ts +1 -0
  489. package/build/cjs/value/deref/index.js +18 -0
  490. package/build/cjs/value/encode/encode.d.ts +6 -0
  491. package/build/cjs/value/encode/encode.js +15 -0
  492. package/build/cjs/value/encode/index.d.ts +1 -0
  493. package/build/cjs/value/encode/index.js +18 -0
  494. package/build/cjs/value/equal/equal.d.ts +2 -0
  495. package/build/cjs/value/equal/equal.js +50 -0
  496. package/build/cjs/value/equal/index.d.ts +1 -0
  497. package/build/cjs/value/equal/index.js +18 -0
  498. package/build/cjs/value/guard/guard.d.ts +74 -0
  499. package/build/cjs/value/guard/guard.js +195 -0
  500. package/build/cjs/value/guard/index.d.ts +1 -0
  501. package/build/cjs/value/guard/index.js +18 -0
  502. package/build/cjs/value/hash/hash.d.ts +7 -0
  503. package/build/cjs/value/hash/hash.js +152 -0
  504. package/build/cjs/value/hash/index.d.ts +1 -0
  505. package/build/cjs/value/hash/index.js +18 -0
  506. package/build/cjs/value/index.d.ts +20 -0
  507. package/build/cjs/value/index.js +53 -0
  508. package/build/cjs/value/mutate/index.d.ts +1 -0
  509. package/build/cjs/value/mutate/index.js +18 -0
  510. package/build/cjs/value/mutate/mutate.d.ts +9 -0
  511. package/build/cjs/value/mutate/mutate.js +104 -0
  512. package/build/cjs/value/parse/index.d.ts +1 -0
  513. package/build/cjs/value/parse/index.js +18 -0
  514. package/build/cjs/value/parse/parse.d.ts +22 -0
  515. package/build/cjs/value/parse/parse.js +87 -0
  516. package/build/cjs/value/pointer/index.d.ts +1 -0
  517. package/build/cjs/value/pointer/index.js +38 -0
  518. package/build/cjs/value/pointer/pointer.d.ts +22 -0
  519. package/build/cjs/value/pointer/pointer.js +126 -0
  520. package/build/cjs/value/transform/decode.d.ts +22 -0
  521. package/build/cjs/value/transform/decode.js +214 -0
  522. package/build/cjs/value/transform/encode.d.ts +23 -0
  523. package/build/cjs/value/transform/encode.js +225 -0
  524. package/build/cjs/value/transform/has.d.ts +3 -0
  525. package/build/cjs/value/transform/has.js +133 -0
  526. package/build/cjs/value/transform/index.d.ts +3 -0
  527. package/build/cjs/value/transform/index.js +20 -0
  528. package/build/cjs/value/value/index.d.ts +1 -0
  529. package/build/cjs/value/value/index.js +38 -0
  530. package/build/cjs/value/value/value.d.ts +16 -0
  531. package/build/cjs/value/value/value.js +39 -0
  532. package/build/esm/compiler/compiler.d.mts +55 -0
  533. package/build/esm/compiler/compiler.mjs +663 -0
  534. package/build/esm/compiler/index.d.mts +2 -0
  535. package/build/esm/compiler/index.mjs +2 -0
  536. package/build/esm/errors/errors.d.mts +91 -0
  537. package/build/esm/errors/errors.mjs +592 -0
  538. package/build/esm/errors/function.d.mts +21 -0
  539. package/build/esm/errors/function.mjs +147 -0
  540. package/build/esm/errors/index.d.mts +2 -0
  541. package/build/esm/errors/index.mjs +2 -0
  542. package/build/esm/index.d.mts +71 -0
  543. package/build/esm/index.mjs +80 -0
  544. package/build/esm/parser/index.d.mts +2 -0
  545. package/build/esm/parser/index.mjs +2 -0
  546. package/build/esm/parser/runtime/guard.d.mts +23 -0
  547. package/build/esm/parser/runtime/guard.mjs +72 -0
  548. package/build/esm/parser/runtime/index.d.mts +5 -0
  549. package/build/esm/parser/runtime/index.mjs +5 -0
  550. package/build/esm/parser/runtime/module.d.mts +9 -0
  551. package/build/esm/parser/runtime/module.mjs +17 -0
  552. package/build/esm/parser/runtime/parse.d.mts +9 -0
  553. package/build/esm/parser/runtime/parse.mjs +123 -0
  554. package/build/esm/parser/runtime/token.d.mts +8 -0
  555. package/build/esm/parser/runtime/token.mjs +223 -0
  556. package/build/esm/parser/runtime/types.d.mts +98 -0
  557. package/build/esm/parser/runtime/types.mjs +55 -0
  558. package/build/esm/parser/static/index.d.mts +3 -0
  559. package/build/esm/parser/static/index.mjs +3 -0
  560. package/build/esm/parser/static/parse.d.mts +20 -0
  561. package/build/esm/parser/static/parse.mjs +1 -0
  562. package/build/esm/parser/static/token.d.mts +108 -0
  563. package/build/esm/parser/static/token.mjs +1 -0
  564. package/build/esm/parser/static/types.d.mts +69 -0
  565. package/build/esm/parser/static/types.mjs +1 -0
  566. package/build/esm/syntax/index.d.mts +1 -0
  567. package/build/esm/syntax/index.mjs +1 -0
  568. package/build/esm/syntax/mapping.d.mts +167 -0
  569. package/build/esm/syntax/mapping.mjs +386 -0
  570. package/build/esm/syntax/parser.d.mts +162 -0
  571. package/build/esm/syntax/parser.mjs +78 -0
  572. package/build/esm/syntax/syntax.d.mts +12 -0
  573. package/build/esm/syntax/syntax.mjs +16 -0
  574. package/build/esm/system/index.d.mts +2 -0
  575. package/build/esm/system/index.mjs +2 -0
  576. package/build/esm/system/policy.d.mts +29 -0
  577. package/build/esm/system/policy.mjs +54 -0
  578. package/build/esm/system/system.d.mts +16 -0
  579. package/build/esm/system/system.mjs +37 -0
  580. package/build/esm/type/any/any.d.mts +8 -0
  581. package/build/esm/type/any/any.mjs +6 -0
  582. package/build/esm/type/any/index.d.mts +1 -0
  583. package/build/esm/type/any/index.mjs +1 -0
  584. package/build/esm/type/argument/argument.d.mts +9 -0
  585. package/build/esm/type/argument/argument.mjs +6 -0
  586. package/build/esm/type/argument/index.d.mts +1 -0
  587. package/build/esm/type/argument/index.mjs +1 -0
  588. package/build/esm/type/array/array.d.mts +28 -0
  589. package/build/esm/type/array/array.mjs +6 -0
  590. package/build/esm/type/array/index.d.mts +1 -0
  591. package/build/esm/type/array/index.mjs +1 -0
  592. package/build/esm/type/async-iterator/async-iterator.d.mts +11 -0
  593. package/build/esm/type/async-iterator/async-iterator.mjs +6 -0
  594. package/build/esm/type/async-iterator/index.d.mts +1 -0
  595. package/build/esm/type/async-iterator/index.mjs +1 -0
  596. package/build/esm/type/awaited/awaited.d.mts +14 -0
  597. package/build/esm/type/awaited/awaited.mjs +37 -0
  598. package/build/esm/type/awaited/index.d.mts +1 -0
  599. package/build/esm/type/awaited/index.mjs +1 -0
  600. package/build/esm/type/bigint/bigint.d.mts +16 -0
  601. package/build/esm/type/bigint/bigint.mjs +6 -0
  602. package/build/esm/type/bigint/index.d.mts +1 -0
  603. package/build/esm/type/bigint/index.mjs +1 -0
  604. package/build/esm/type/boolean/boolean.d.mts +9 -0
  605. package/build/esm/type/boolean/boolean.mjs +6 -0
  606. package/build/esm/type/boolean/index.d.mts +1 -0
  607. package/build/esm/type/boolean/index.mjs +1 -0
  608. package/build/esm/type/clone/index.d.mts +2 -0
  609. package/build/esm/type/clone/index.mjs +2 -0
  610. package/build/esm/type/clone/type.d.mts +5 -0
  611. package/build/esm/type/clone/type.mjs +9 -0
  612. package/build/esm/type/clone/value.d.mts +2 -0
  613. package/build/esm/type/clone/value.mjs +36 -0
  614. package/build/esm/type/composite/composite.d.mts +18 -0
  615. package/build/esm/type/composite/composite.mjs +42 -0
  616. package/build/esm/type/composite/index.d.mts +1 -0
  617. package/build/esm/type/composite/index.mjs +1 -0
  618. package/build/esm/type/computed/computed.d.mts +9 -0
  619. package/build/esm/type/computed/computed.mjs +6 -0
  620. package/build/esm/type/computed/index.d.mts +1 -0
  621. package/build/esm/type/computed/index.mjs +1 -0
  622. package/build/esm/type/const/const.d.mts +27 -0
  623. package/build/esm/type/const/const.mjs +54 -0
  624. package/build/esm/type/const/index.d.mts +1 -0
  625. package/build/esm/type/const/index.mjs +1 -0
  626. package/build/esm/type/constructor/constructor.d.mts +23 -0
  627. package/build/esm/type/constructor/constructor.mjs +6 -0
  628. package/build/esm/type/constructor/index.d.mts +1 -0
  629. package/build/esm/type/constructor/index.mjs +1 -0
  630. package/build/esm/type/constructor-parameters/constructor-parameters.d.mts +7 -0
  631. package/build/esm/type/constructor-parameters/constructor-parameters.mjs +7 -0
  632. package/build/esm/type/constructor-parameters/index.d.mts +1 -0
  633. package/build/esm/type/constructor-parameters/index.mjs +1 -0
  634. package/build/esm/type/create/immutable.d.mts +2 -0
  635. package/build/esm/type/create/immutable.mjs +33 -0
  636. package/build/esm/type/create/index.d.mts +1 -0
  637. package/build/esm/type/create/index.mjs +1 -0
  638. package/build/esm/type/create/type.d.mts +3 -0
  639. package/build/esm/type/create/type.mjs +15 -0
  640. package/build/esm/type/date/date.d.mts +21 -0
  641. package/build/esm/type/date/date.mjs +6 -0
  642. package/build/esm/type/date/index.d.mts +1 -0
  643. package/build/esm/type/date/index.mjs +1 -0
  644. package/build/esm/type/discard/discard.d.mts +2 -0
  645. package/build/esm/type/discard/discard.mjs +8 -0
  646. package/build/esm/type/discard/index.d.mts +1 -0
  647. package/build/esm/type/discard/index.mjs +1 -0
  648. package/build/esm/type/enum/enum.d.mts +14 -0
  649. package/build/esm/type/enum/enum.mjs +18 -0
  650. package/build/esm/type/enum/index.d.mts +1 -0
  651. package/build/esm/type/enum/index.mjs +1 -0
  652. package/build/esm/type/error/error.d.mts +4 -0
  653. package/build/esm/type/error/error.mjs +6 -0
  654. package/build/esm/type/error/index.d.mts +1 -0
  655. package/build/esm/type/error/index.mjs +1 -0
  656. package/build/esm/type/exclude/exclude-from-mapped-result.d.mts +11 -0
  657. package/build/esm/type/exclude/exclude-from-mapped-result.mjs +18 -0
  658. package/build/esm/type/exclude/exclude-from-template-literal.d.mts +5 -0
  659. package/build/esm/type/exclude/exclude-from-template-literal.mjs +5 -0
  660. package/build/esm/type/exclude/exclude.d.mts +21 -0
  661. package/build/esm/type/exclude/exclude.mjs +25 -0
  662. package/build/esm/type/exclude/index.d.mts +3 -0
  663. package/build/esm/type/exclude/index.mjs +3 -0
  664. package/build/esm/type/extends/extends-check.d.mts +10 -0
  665. package/build/esm/type/extends/extends-check.mjs +635 -0
  666. package/build/esm/type/extends/extends-from-mapped-key.d.mts +14 -0
  667. package/build/esm/type/extends/extends-from-mapped-key.mjs +25 -0
  668. package/build/esm/type/extends/extends-from-mapped-result.d.mts +11 -0
  669. package/build/esm/type/extends/extends-from-mapped-result.mjs +19 -0
  670. package/build/esm/type/extends/extends-undefined.d.mts +3 -0
  671. package/build/esm/type/extends/extends-undefined.mjs +20 -0
  672. package/build/esm/type/extends/extends.d.mts +16 -0
  673. package/build/esm/type/extends/extends.mjs +23 -0
  674. package/build/esm/type/extends/index.d.mts +5 -0
  675. package/build/esm/type/extends/index.mjs +5 -0
  676. package/build/esm/type/extract/extract-from-mapped-result.d.mts +11 -0
  677. package/build/esm/type/extract/extract-from-mapped-result.mjs +18 -0
  678. package/build/esm/type/extract/extract-from-template-literal.d.mts +5 -0
  679. package/build/esm/type/extract/extract-from-template-literal.mjs +5 -0
  680. package/build/esm/type/extract/extract.d.mts +21 -0
  681. package/build/esm/type/extract/extract.mjs +25 -0
  682. package/build/esm/type/extract/index.d.mts +3 -0
  683. package/build/esm/type/extract/index.mjs +3 -0
  684. package/build/esm/type/function/function.d.mts +23 -0
  685. package/build/esm/type/function/function.mjs +6 -0
  686. package/build/esm/type/function/index.d.mts +1 -0
  687. package/build/esm/type/function/index.mjs +1 -0
  688. package/build/esm/type/guard/index.d.mts +3 -0
  689. package/build/esm/type/guard/index.mjs +3 -0
  690. package/build/esm/type/guard/kind.d.mts +147 -0
  691. package/build/esm/type/guard/kind.mjs +235 -0
  692. package/build/esm/type/guard/type.d.mts +152 -0
  693. package/build/esm/type/guard/type.mjs +509 -0
  694. package/build/esm/type/guard/value.d.mts +34 -0
  695. package/build/esm/type/guard/value.mjs +70 -0
  696. package/build/esm/type/helpers/helpers.d.mts +42 -0
  697. package/build/esm/type/helpers/helpers.mjs +4 -0
  698. package/build/esm/type/helpers/index.d.mts +1 -0
  699. package/build/esm/type/helpers/index.mjs +1 -0
  700. package/build/esm/type/index.d.mts +71 -0
  701. package/build/esm/type/index.mjs +71 -0
  702. package/build/esm/type/indexed/index.d.mts +4 -0
  703. package/build/esm/type/indexed/index.mjs +4 -0
  704. package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +13 -0
  705. package/build/esm/type/indexed/indexed-from-mapped-key.mjs +22 -0
  706. package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +12 -0
  707. package/build/esm/type/indexed/indexed-from-mapped-result.mjs +20 -0
  708. package/build/esm/type/indexed/indexed-property-keys.d.mts +14 -0
  709. package/build/esm/type/indexed/indexed-property-keys.mjs +32 -0
  710. package/build/esm/type/indexed/indexed.d.mts +52 -0
  711. package/build/esm/type/indexed/indexed.mjs +91 -0
  712. package/build/esm/type/instance-type/index.d.mts +1 -0
  713. package/build/esm/type/instance-type/index.mjs +1 -0
  714. package/build/esm/type/instance-type/instance-type.d.mts +6 -0
  715. package/build/esm/type/instance-type/instance-type.mjs +7 -0
  716. package/build/esm/type/instantiate/index.d.mts +1 -0
  717. package/build/esm/type/instantiate/index.mjs +1 -0
  718. package/build/esm/type/instantiate/instantiate.d.mts +50 -0
  719. package/build/esm/type/instantiate/instantiate.mjs +115 -0
  720. package/build/esm/type/integer/index.d.mts +1 -0
  721. package/build/esm/type/integer/index.mjs +1 -0
  722. package/build/esm/type/integer/integer.d.mts +16 -0
  723. package/build/esm/type/integer/integer.mjs +6 -0
  724. package/build/esm/type/intersect/index.d.mts +3 -0
  725. package/build/esm/type/intersect/index.mjs +3 -0
  726. package/build/esm/type/intersect/intersect-create.d.mts +3 -0
  727. package/build/esm/type/intersect/intersect-create.mjs +19 -0
  728. package/build/esm/type/intersect/intersect-evaluated.d.mts +13 -0
  729. package/build/esm/type/intersect/intersect-evaluated.mjs +38 -0
  730. package/build/esm/type/intersect/intersect-type.d.mts +15 -0
  731. package/build/esm/type/intersect/intersect-type.mjs +1 -0
  732. package/build/esm/type/intersect/intersect.d.mts +6 -0
  733. package/build/esm/type/intersect/intersect.mjs +17 -0
  734. package/build/esm/type/intrinsic/capitalize.d.mts +5 -0
  735. package/build/esm/type/intrinsic/capitalize.mjs +5 -0
  736. package/build/esm/type/intrinsic/index.d.mts +6 -0
  737. package/build/esm/type/intrinsic/index.mjs +6 -0
  738. package/build/esm/type/intrinsic/intrinsic-from-mapped-key.d.mts +14 -0
  739. package/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs +26 -0
  740. package/build/esm/type/intrinsic/intrinsic.d.mts +16 -0
  741. package/build/esm/type/intrinsic/intrinsic.mjs +64 -0
  742. package/build/esm/type/intrinsic/lowercase.d.mts +5 -0
  743. package/build/esm/type/intrinsic/lowercase.mjs +5 -0
  744. package/build/esm/type/intrinsic/uncapitalize.d.mts +5 -0
  745. package/build/esm/type/intrinsic/uncapitalize.mjs +5 -0
  746. package/build/esm/type/intrinsic/uppercase.d.mts +5 -0
  747. package/build/esm/type/intrinsic/uppercase.mjs +5 -0
  748. package/build/esm/type/iterator/index.d.mts +1 -0
  749. package/build/esm/type/iterator/index.mjs +1 -0
  750. package/build/esm/type/iterator/iterator.d.mts +11 -0
  751. package/build/esm/type/iterator/iterator.mjs +6 -0
  752. package/build/esm/type/keyof/index.d.mts +4 -0
  753. package/build/esm/type/keyof/index.mjs +4 -0
  754. package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +12 -0
  755. package/build/esm/type/keyof/keyof-from-mapped-result.mjs +19 -0
  756. package/build/esm/type/keyof/keyof-property-entries.d.mts +7 -0
  757. package/build/esm/type/keyof/keyof-property-entries.mjs +12 -0
  758. package/build/esm/type/keyof/keyof-property-keys.d.mts +24 -0
  759. package/build/esm/type/keyof/keyof-property-keys.mjs +73 -0
  760. package/build/esm/type/keyof/keyof.d.mts +21 -0
  761. package/build/esm/type/keyof/keyof.mjs +35 -0
  762. package/build/esm/type/literal/index.d.mts +1 -0
  763. package/build/esm/type/literal/index.mjs +1 -0
  764. package/build/esm/type/literal/literal.d.mts +10 -0
  765. package/build/esm/type/literal/literal.mjs +10 -0
  766. package/build/esm/type/mapped/index.d.mts +3 -0
  767. package/build/esm/type/mapped/index.mjs +3 -0
  768. package/build/esm/type/mapped/mapped-key.d.mts +8 -0
  769. package/build/esm/type/mapped/mapped-key.mjs +9 -0
  770. package/build/esm/type/mapped/mapped-result.d.mts +9 -0
  771. package/build/esm/type/mapped/mapped-result.mjs +9 -0
  772. package/build/esm/type/mapped/mapped.d.mts +47 -0
  773. package/build/esm/type/mapped/mapped.mjs +102 -0
  774. package/build/esm/type/module/compute.d.mts +59 -0
  775. package/build/esm/type/module/compute.mjs +166 -0
  776. package/build/esm/type/module/index.d.mts +1 -0
  777. package/build/esm/type/module/index.mjs +1 -0
  778. package/build/esm/type/module/infer.d.mts +49 -0
  779. package/build/esm/type/module/infer.mjs +1 -0
  780. package/build/esm/type/module/module.d.mts +27 -0
  781. package/build/esm/type/module/module.mjs +32 -0
  782. package/build/esm/type/never/index.d.mts +1 -0
  783. package/build/esm/type/never/index.mjs +1 -0
  784. package/build/esm/type/never/never.d.mts +9 -0
  785. package/build/esm/type/never/never.mjs +6 -0
  786. package/build/esm/type/not/index.d.mts +1 -0
  787. package/build/esm/type/not/index.mjs +1 -0
  788. package/build/esm/type/not/not.d.mts +10 -0
  789. package/build/esm/type/not/not.mjs +6 -0
  790. package/build/esm/type/null/index.d.mts +1 -0
  791. package/build/esm/type/null/index.mjs +1 -0
  792. package/build/esm/type/null/null.d.mts +9 -0
  793. package/build/esm/type/null/null.mjs +6 -0
  794. package/build/esm/type/number/index.d.mts +1 -0
  795. package/build/esm/type/number/index.mjs +1 -0
  796. package/build/esm/type/number/number.d.mts +16 -0
  797. package/build/esm/type/number/number.mjs +6 -0
  798. package/build/esm/type/object/index.d.mts +1 -0
  799. package/build/esm/type/object/index.mjs +1 -0
  800. package/build/esm/type/object/object.d.mts +51 -0
  801. package/build/esm/type/object/object.mjs +18 -0
  802. package/build/esm/type/omit/index.d.mts +3 -0
  803. package/build/esm/type/omit/index.mjs +3 -0
  804. package/build/esm/type/omit/omit-from-mapped-key.d.mts +12 -0
  805. package/build/esm/type/omit/omit-from-mapped-key.mjs +22 -0
  806. package/build/esm/type/omit/omit-from-mapped-result.d.mts +12 -0
  807. package/build/esm/type/omit/omit-from-mapped-result.mjs +19 -0
  808. package/build/esm/type/omit/omit.d.mts +36 -0
  809. package/build/esm/type/omit/omit.mjs +71 -0
  810. package/build/esm/type/optional/index.d.mts +2 -0
  811. package/build/esm/type/optional/index.mjs +2 -0
  812. package/build/esm/type/optional/optional-from-mapped-result.d.mts +10 -0
  813. package/build/esm/type/optional/optional-from-mapped-result.mjs +18 -0
  814. package/build/esm/type/optional/optional.d.mts +20 -0
  815. package/build/esm/type/optional/optional.mjs +22 -0
  816. package/build/esm/type/parameters/index.d.mts +1 -0
  817. package/build/esm/type/parameters/index.mjs +1 -0
  818. package/build/esm/type/parameters/parameters.d.mts +7 -0
  819. package/build/esm/type/parameters/parameters.mjs +7 -0
  820. package/build/esm/type/partial/index.d.mts +2 -0
  821. package/build/esm/type/partial/index.mjs +2 -0
  822. package/build/esm/type/partial/partial-from-mapped-result.d.mts +12 -0
  823. package/build/esm/type/partial/partial-from-mapped-result.mjs +19 -0
  824. package/build/esm/type/partial/partial.d.mts +35 -0
  825. package/build/esm/type/partial/partial.mjs +74 -0
  826. package/build/esm/type/patterns/index.d.mts +1 -0
  827. package/build/esm/type/patterns/index.mjs +1 -0
  828. package/build/esm/type/patterns/patterns.d.mts +8 -0
  829. package/build/esm/type/patterns/patterns.mjs +8 -0
  830. package/build/esm/type/pick/index.d.mts +3 -0
  831. package/build/esm/type/pick/index.mjs +3 -0
  832. package/build/esm/type/pick/pick-from-mapped-key.d.mts +12 -0
  833. package/build/esm/type/pick/pick-from-mapped-key.mjs +24 -0
  834. package/build/esm/type/pick/pick-from-mapped-result.d.mts +12 -0
  835. package/build/esm/type/pick/pick-from-mapped-result.mjs +19 -0
  836. package/build/esm/type/pick/pick.d.mts +36 -0
  837. package/build/esm/type/pick/pick.mjs +66 -0
  838. package/build/esm/type/promise/index.d.mts +1 -0
  839. package/build/esm/type/promise/index.mjs +1 -0
  840. package/build/esm/type/promise/promise.d.mts +11 -0
  841. package/build/esm/type/promise/promise.mjs +6 -0
  842. package/build/esm/type/readonly/index.d.mts +2 -0
  843. package/build/esm/type/readonly/index.mjs +2 -0
  844. package/build/esm/type/readonly/readonly-from-mapped-result.d.mts +10 -0
  845. package/build/esm/type/readonly/readonly-from-mapped-result.mjs +18 -0
  846. package/build/esm/type/readonly/readonly.d.mts +20 -0
  847. package/build/esm/type/readonly/readonly.mjs +22 -0
  848. package/build/esm/type/readonly-optional/index.d.mts +1 -0
  849. package/build/esm/type/readonly-optional/index.mjs +1 -0
  850. package/build/esm/type/readonly-optional/readonly-optional.d.mts +6 -0
  851. package/build/esm/type/readonly-optional/readonly-optional.mjs +6 -0
  852. package/build/esm/type/record/index.d.mts +1 -0
  853. package/build/esm/type/record/index.mjs +1 -0
  854. package/build/esm/type/record/record.d.mts +71 -0
  855. package/build/esm/type/record/record.mjs +116 -0
  856. package/build/esm/type/recursive/index.d.mts +1 -0
  857. package/build/esm/type/recursive/index.mjs +1 -0
  858. package/build/esm/type/recursive/recursive.d.mts +16 -0
  859. package/build/esm/type/recursive/recursive.mjs +15 -0
  860. package/build/esm/type/ref/index.d.mts +1 -0
  861. package/build/esm/type/ref/index.mjs +1 -0
  862. package/build/esm/type/ref/ref.d.mts +41 -0
  863. package/build/esm/type/ref/ref.mjs +10 -0
  864. package/build/esm/type/regexp/index.d.mts +1 -0
  865. package/build/esm/type/regexp/index.mjs +1 -0
  866. package/build/esm/type/regexp/regexp.d.mts +20 -0
  867. package/build/esm/type/regexp/regexp.mjs +8 -0
  868. package/build/esm/type/registry/format.d.mts +13 -0
  869. package/build/esm/type/registry/format.mjs +26 -0
  870. package/build/esm/type/registry/index.d.mts +2 -0
  871. package/build/esm/type/registry/index.mjs +2 -0
  872. package/build/esm/type/registry/type.d.mts +13 -0
  873. package/build/esm/type/registry/type.mjs +26 -0
  874. package/build/esm/type/required/index.d.mts +2 -0
  875. package/build/esm/type/required/index.mjs +2 -0
  876. package/build/esm/type/required/required-from-mapped-result.d.mts +12 -0
  877. package/build/esm/type/required/required-from-mapped-result.mjs +18 -0
  878. package/build/esm/type/required/required.d.mts +35 -0
  879. package/build/esm/type/required/required.mjs +73 -0
  880. package/build/esm/type/rest/index.d.mts +1 -0
  881. package/build/esm/type/rest/index.mjs +1 -0
  882. package/build/esm/type/rest/rest.d.mts +10 -0
  883. package/build/esm/type/rest/rest.mjs +15 -0
  884. package/build/esm/type/return-type/index.d.mts +1 -0
  885. package/build/esm/type/return-type/index.mjs +1 -0
  886. package/build/esm/type/return-type/return-type.d.mts +6 -0
  887. package/build/esm/type/return-type/return-type.mjs +7 -0
  888. package/build/esm/type/schema/anyschema.d.mts +33 -0
  889. package/build/esm/type/schema/anyschema.mjs +1 -0
  890. package/build/esm/type/schema/index.d.mts +2 -0
  891. package/build/esm/type/schema/index.mjs +2 -0
  892. package/build/esm/type/schema/schema.d.mts +29 -0
  893. package/build/esm/type/schema/schema.mjs +1 -0
  894. package/build/esm/type/sets/index.d.mts +1 -0
  895. package/build/esm/type/sets/index.mjs +1 -0
  896. package/build/esm/type/sets/set.d.mts +28 -0
  897. package/build/esm/type/sets/set.mjs +48 -0
  898. package/build/esm/type/static/index.d.mts +1 -0
  899. package/build/esm/type/static/index.mjs +1 -0
  900. package/build/esm/type/static/static.d.mts +39 -0
  901. package/build/esm/type/static/static.mjs +1 -0
  902. package/build/esm/type/string/index.d.mts +1 -0
  903. package/build/esm/type/string/index.mjs +1 -0
  904. package/build/esm/type/string/string.d.mts +25 -0
  905. package/build/esm/type/string/string.mjs +6 -0
  906. package/build/esm/type/symbol/index.d.mts +1 -0
  907. package/build/esm/type/symbol/index.mjs +1 -0
  908. package/build/esm/type/symbol/symbol.d.mts +10 -0
  909. package/build/esm/type/symbol/symbol.mjs +6 -0
  910. package/build/esm/type/symbols/index.d.mts +1 -0
  911. package/build/esm/type/symbols/index.mjs +1 -0
  912. package/build/esm/type/symbols/symbols.d.mts +10 -0
  913. package/build/esm/type/symbols/symbols.mjs +10 -0
  914. package/build/esm/type/template-literal/finite.d.mts +19 -0
  915. package/build/esm/type/template-literal/finite.mjs +49 -0
  916. package/build/esm/type/template-literal/generate.d.mts +21 -0
  917. package/build/esm/type/template-literal/generate.mjs +53 -0
  918. package/build/esm/type/template-literal/index.d.mts +7 -0
  919. package/build/esm/type/template-literal/index.mjs +7 -0
  920. package/build/esm/type/template-literal/parse.d.mts +20 -0
  921. package/build/esm/type/template-literal/parse.mjs +167 -0
  922. package/build/esm/type/template-literal/pattern.d.mts +5 -0
  923. package/build/esm/type/template-literal/pattern.mjs +33 -0
  924. package/build/esm/type/template-literal/syntax.d.mts +20 -0
  925. package/build/esm/type/template-literal/syntax.mjs +55 -0
  926. package/build/esm/type/template-literal/template-literal.d.mts +30 -0
  927. package/build/esm/type/template-literal/template-literal.mjs +13 -0
  928. package/build/esm/type/template-literal/union.d.mts +9 -0
  929. package/build/esm/type/template-literal/union.mjs +9 -0
  930. package/build/esm/type/transform/index.d.mts +1 -0
  931. package/build/esm/type/transform/index.mjs +1 -0
  932. package/build/esm/type/transform/transform.d.mts +30 -0
  933. package/build/esm/type/transform/transform.mjs +40 -0
  934. package/build/esm/type/tuple/index.d.mts +1 -0
  935. package/build/esm/type/tuple/index.mjs +1 -0
  936. package/build/esm/type/tuple/tuple.d.mts +16 -0
  937. package/build/esm/type/tuple/tuple.mjs +9 -0
  938. package/build/esm/type/type/index.d.mts +6 -0
  939. package/build/esm/type/type/index.mjs +13 -0
  940. package/build/esm/type/type/javascript.d.mts +64 -0
  941. package/build/esm/type/type/javascript.mjs +99 -0
  942. package/build/esm/type/type/json.d.mts +208 -0
  943. package/build/esm/type/type/json.mjs +221 -0
  944. package/build/esm/type/type/type.d.mts +59 -0
  945. package/build/esm/type/type/type.mjs +62 -0
  946. package/build/esm/type/uint8array/index.d.mts +1 -0
  947. package/build/esm/type/uint8array/index.mjs +1 -0
  948. package/build/esm/type/uint8array/uint8array.d.mts +13 -0
  949. package/build/esm/type/uint8array/uint8array.mjs +6 -0
  950. package/build/esm/type/undefined/index.d.mts +1 -0
  951. package/build/esm/type/undefined/index.mjs +1 -0
  952. package/build/esm/type/undefined/undefined.d.mts +9 -0
  953. package/build/esm/type/undefined/undefined.mjs +6 -0
  954. package/build/esm/type/union/index.d.mts +3 -0
  955. package/build/esm/type/union/index.mjs +3 -0
  956. package/build/esm/type/union/union-create.d.mts +3 -0
  957. package/build/esm/type/union/union-create.mjs +5 -0
  958. package/build/esm/type/union/union-evaluated.d.mts +13 -0
  959. package/build/esm/type/union/union-evaluated.mjs +36 -0
  960. package/build/esm/type/union/union-type.d.mts +12 -0
  961. package/build/esm/type/union/union-type.mjs +1 -0
  962. package/build/esm/type/union/union.d.mts +6 -0
  963. package/build/esm/type/union/union.mjs +10 -0
  964. package/build/esm/type/unknown/index.d.mts +1 -0
  965. package/build/esm/type/unknown/index.mjs +1 -0
  966. package/build/esm/type/unknown/unknown.d.mts +8 -0
  967. package/build/esm/type/unknown/unknown.mjs +6 -0
  968. package/build/esm/type/unsafe/index.d.mts +1 -0
  969. package/build/esm/type/unsafe/index.mjs +1 -0
  970. package/build/esm/type/unsafe/unsafe.d.mts +11 -0
  971. package/build/esm/type/unsafe/unsafe.mjs +6 -0
  972. package/build/esm/type/void/index.d.mts +1 -0
  973. package/build/esm/type/void/index.mjs +1 -0
  974. package/build/esm/type/void/void.d.mts +9 -0
  975. package/build/esm/type/void/void.mjs +6 -0
  976. package/build/esm/value/assert/assert.d.mts +15 -0
  977. package/build/esm/value/assert/assert.mjs +49 -0
  978. package/build/esm/value/assert/index.d.mts +1 -0
  979. package/build/esm/value/assert/index.mjs +1 -0
  980. package/build/esm/value/cast/cast.d.mts +11 -0
  981. package/build/esm/value/cast/cast.mjs +235 -0
  982. package/build/esm/value/cast/index.d.mts +1 -0
  983. package/build/esm/value/cast/index.mjs +1 -0
  984. package/build/esm/value/check/check.d.mts +11 -0
  985. package/build/esm/value/check/check.mjs +470 -0
  986. package/build/esm/value/check/index.d.mts +1 -0
  987. package/build/esm/value/check/index.mjs +1 -0
  988. package/build/esm/value/clean/clean.d.mts +5 -0
  989. package/build/esm/value/clean/clean.mjs +145 -0
  990. package/build/esm/value/clean/index.d.mts +1 -0
  991. package/build/esm/value/clean/index.mjs +1 -0
  992. package/build/esm/value/clone/clone.d.mts +2 -0
  993. package/build/esm/value/clone/clone.mjs +56 -0
  994. package/build/esm/value/clone/index.d.mts +1 -0
  995. package/build/esm/value/clone/index.mjs +1 -0
  996. package/build/esm/value/convert/convert.d.mts +5 -0
  997. package/build/esm/value/convert/convert.mjs +260 -0
  998. package/build/esm/value/convert/index.d.mts +1 -0
  999. package/build/esm/value/convert/index.mjs +1 -0
  1000. package/build/esm/value/create/create.d.mts +11 -0
  1001. package/build/esm/value/create/create.mjs +468 -0
  1002. package/build/esm/value/create/index.d.mts +1 -0
  1003. package/build/esm/value/create/index.mjs +1 -0
  1004. package/build/esm/value/decode/decode.d.mts +6 -0
  1005. package/build/esm/value/decode/decode.mjs +10 -0
  1006. package/build/esm/value/decode/index.d.mts +1 -0
  1007. package/build/esm/value/decode/index.mjs +1 -0
  1008. package/build/esm/value/default/default.d.mts +5 -0
  1009. package/build/esm/value/default/default.mjs +172 -0
  1010. package/build/esm/value/default/index.d.mts +1 -0
  1011. package/build/esm/value/default/index.mjs +1 -0
  1012. package/build/esm/value/delta/delta.d.mts +32 -0
  1013. package/build/esm/value/delta/delta.mjs +171 -0
  1014. package/build/esm/value/delta/index.d.mts +1 -0
  1015. package/build/esm/value/delta/index.mjs +1 -0
  1016. package/build/esm/value/deref/deref.d.mts +12 -0
  1017. package/build/esm/value/deref/deref.mjs +29 -0
  1018. package/build/esm/value/deref/index.d.mts +1 -0
  1019. package/build/esm/value/deref/index.mjs +1 -0
  1020. package/build/esm/value/encode/encode.d.mts +6 -0
  1021. package/build/esm/value/encode/encode.mjs +11 -0
  1022. package/build/esm/value/encode/index.d.mts +1 -0
  1023. package/build/esm/value/encode/index.mjs +1 -0
  1024. package/build/esm/value/equal/equal.d.mts +2 -0
  1025. package/build/esm/value/equal/equal.mjs +46 -0
  1026. package/build/esm/value/equal/index.d.mts +1 -0
  1027. package/build/esm/value/equal/index.mjs +1 -0
  1028. package/build/esm/value/guard/guard.d.mts +74 -0
  1029. package/build/esm/value/guard/guard.mjs +158 -0
  1030. package/build/esm/value/guard/index.d.mts +1 -0
  1031. package/build/esm/value/guard/index.mjs +1 -0
  1032. package/build/esm/value/hash/hash.d.mts +7 -0
  1033. package/build/esm/value/hash/hash.mjs +146 -0
  1034. package/build/esm/value/hash/index.d.mts +1 -0
  1035. package/build/esm/value/hash/index.mjs +1 -0
  1036. package/build/esm/value/index.d.mts +20 -0
  1037. package/build/esm/value/index.mjs +32 -0
  1038. package/build/esm/value/mutate/index.d.mts +1 -0
  1039. package/build/esm/value/mutate/index.mjs +1 -0
  1040. package/build/esm/value/mutate/mutate.d.mts +9 -0
  1041. package/build/esm/value/mutate/mutate.mjs +98 -0
  1042. package/build/esm/value/parse/index.d.mts +1 -0
  1043. package/build/esm/value/parse/index.mjs +1 -0
  1044. package/build/esm/value/parse/parse.d.mts +22 -0
  1045. package/build/esm/value/parse/parse.mjs +81 -0
  1046. package/build/esm/value/pointer/index.d.mts +1 -0
  1047. package/build/esm/value/pointer/index.mjs +1 -0
  1048. package/build/esm/value/pointer/pointer.d.mts +22 -0
  1049. package/build/esm/value/pointer/pointer.mjs +115 -0
  1050. package/build/esm/value/transform/decode.d.mts +22 -0
  1051. package/build/esm/value/transform/decode.mjs +207 -0
  1052. package/build/esm/value/transform/encode.d.mts +23 -0
  1053. package/build/esm/value/transform/encode.mjs +218 -0
  1054. package/build/esm/value/transform/has.d.mts +3 -0
  1055. package/build/esm/value/transform/has.mjs +129 -0
  1056. package/build/esm/value/transform/index.d.mts +3 -0
  1057. package/build/esm/value/transform/index.mjs +3 -0
  1058. package/build/esm/value/value/index.d.mts +1 -0
  1059. package/build/esm/value/value/index.mjs +1 -0
  1060. package/build/esm/value/value/value.d.mts +16 -0
  1061. package/build/esm/value/value/value.mjs +16 -0
  1062. package/changes.json +5 -0
  1063. package/compiler/package.json +4 -0
  1064. package/errors/package.json +4 -0
  1065. package/license +25 -0
  1066. package/package.json +128 -0
  1067. package/parser/package.json +4 -0
  1068. package/readme.md +1865 -0
  1069. package/syntax/package.json +4 -0
  1070. package/system/package.json +4 -0
  1071. package/type/package.json +4 -0
  1072. package/value/package.json +4 -0
package/readme.md ADDED
@@ -0,0 +1,1865 @@
1
+ <div align='center'>
2
+
3
+ <h1>TypeBox 0.34.x</h1>
4
+
5
+ <p>Json Schema Type Builder with Static Type Resolution for TypeScript</p>
6
+
7
+ <img src="https://raw.githubusercontent.com/sinclairzx81/typebox-legacy/refs/heads/main/typebox.png" />
8
+
9
+ <br />
10
+ <br />
11
+
12
+ [![npm version](https://badge.fury.io/js/%40sinclair%2Ftypebox.svg)](https://badge.fury.io/js/%40sinclair%2Ftypebox)
13
+ [![Downloads](https://img.shields.io/npm/dm/%40sinclair%2Ftypebox.svg)](https://www.npmjs.com/package/%40sinclair%2Ftypebox)
14
+ [![Build](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml/badge.svg)](https://github.com/sinclairzx81/typebox/actions/workflows/build.yml)
15
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
16
+
17
+ </div>
18
+
19
+ <a name="Install"></a>
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ $ npm install @sinclair/typebox # TypeBox-Legacy | 0.34.x
25
+
26
+ $ npm install typebox # TypeBox | 1.0.x
27
+ ```
28
+
29
+ ## Example
30
+
31
+ ```typescript
32
+ import { Type, type Static } from '@sinclair/typebox'
33
+
34
+ const T = Type.Object({ // const T = {
35
+ x: Type.Number(), // type: 'object',
36
+ y: Type.Number(), // required: ['x', 'y', 'z'],
37
+ z: Type.Number() // properties: {
38
+ }) // x: { type: 'number' },
39
+ // y: { type: 'number' },
40
+ // z: { type: 'number' }
41
+ // }
42
+ // }
43
+
44
+ type T = Static<typeof T> // type T = {
45
+ // x: number,
46
+ // y: number,
47
+ // z: number
48
+ // }
49
+ ```
50
+
51
+
52
+ <a name="Overview"></a>
53
+
54
+ ## Overview
55
+
56
+ > ⚠️ TypeBox versions (pre-1.0) will continue active maintenance through 2026 and beyond. This repository services as the OIDC publishing environment for the `@sinclair/typebox` package scope on NPM. For TypeBox versions 1.0 and above, refer to https://github.com/sinclairzx81/typebox
57
+
58
+ TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
59
+
60
+ This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
61
+
62
+ License MIT
63
+
64
+ ## Contents
65
+ - [Install](#install)
66
+ - [Overview](#overview)
67
+ - [Usage](#usage)
68
+ - [Types](#types)
69
+ - [Json](#types-json)
70
+ - [JavaScript](#types-javascript)
71
+ - [Options](#types-options)
72
+ - [Properties](#types-properties)
73
+ - [Generics](#types-generics)
74
+ - [Recursive](#types-recursive)
75
+ - [Modules](#types-modules)
76
+ - [Template Literal](#types-template-literal)
77
+ - [Indexed](#types-indexed)
78
+ - [Mapped](#types-mapped)
79
+ - [Conditional](#types-conditional)
80
+ - [Transform](#types-transform)
81
+ - [Guard](#types-guard)
82
+ - [Unsafe](#types-unsafe)
83
+ - [Values](#values)
84
+ - [Assert](#values-assert)
85
+ - [Create](#values-create)
86
+ - [Clone](#values-clone)
87
+ - [Check](#values-check)
88
+ - [Convert](#values-convert)
89
+ - [Default](#values-default)
90
+ - [Clean](#values-clean)
91
+ - [Cast](#values-cast)
92
+ - [Decode](#values-decode)
93
+ - [Encode](#values-decode)
94
+ - [Parse](#values-parse)
95
+ - [Equal](#values-equal)
96
+ - [Hash](#values-hash)
97
+ - [Diff](#values-diff)
98
+ - [Patch](#values-patch)
99
+ - [Errors](#values-errors)
100
+ - [Mutate](#values-mutate)
101
+ - [Pointer](#values-pointer)
102
+ - [Syntax](#syntax)
103
+ - [Create](#syntax-create)
104
+ - [Parameters](#syntax-parameters)
105
+ - [Generics](#syntax-generics)
106
+ - [Options](#syntax-options)
107
+ - [NoInfer](#syntax-no-infer)
108
+ - [TypeRegistry](#typeregistry)
109
+ - [Type](#typeregistry-type)
110
+ - [Format](#typeregistry-format)
111
+ - [TypeCheck](#typecheck)
112
+ - [Ajv](#typecheck-ajv)
113
+ - [TypeCompiler](#typecheck-typecompiler)
114
+ - [TypeMap](#typemap)
115
+ - [Usage](#typemap-usage)
116
+ - [TypeSystem](#typesystem)
117
+ - [Policies](#typesystem-policies)
118
+ - [Error Function](#error-function)
119
+ - [Workbench](#workbench)
120
+ - [Codegen](#codegen)
121
+ - [Ecosystem](#ecosystem)
122
+ - [Benchmark](#benchmark)
123
+ - [Compile](#benchmark-compile)
124
+ - [Validate](#benchmark-validate)
125
+ - [Compression](#benchmark-compression)
126
+ - [Contribute](#contribute)
127
+
128
+ <a name="usage"></a>
129
+
130
+ ## Usage
131
+
132
+ The following shows general usage.
133
+
134
+ ```typescript
135
+ import { Type, type Static } from '@sinclair/typebox'
136
+
137
+ //--------------------------------------------------------------------------------------------
138
+ //
139
+ // Let's say you have the following type ...
140
+ //
141
+ //--------------------------------------------------------------------------------------------
142
+
143
+ type T = {
144
+ id: string,
145
+ name: string,
146
+ timestamp: number
147
+ }
148
+
149
+ //--------------------------------------------------------------------------------------------
150
+ //
151
+ // ... you can express this type in the following way.
152
+ //
153
+ //--------------------------------------------------------------------------------------------
154
+
155
+ const T = Type.Object({ // const T = {
156
+ id: Type.String(), // type: 'object',
157
+ name: Type.String(), // properties: {
158
+ timestamp: Type.Integer() // id: {
159
+ }) // type: 'string'
160
+ // },
161
+ // name: {
162
+ // type: 'string'
163
+ // },
164
+ // timestamp: {
165
+ // type: 'integer'
166
+ // }
167
+ // },
168
+ // required: [
169
+ // 'id',
170
+ // 'name',
171
+ // 'timestamp'
172
+ // ]
173
+ // }
174
+
175
+ //--------------------------------------------------------------------------------------------
176
+ //
177
+ // ... then infer back to the original static type this way.
178
+ //
179
+ //--------------------------------------------------------------------------------------------
180
+
181
+ type T = Static<typeof T> // type T = {
182
+ // id: string,
183
+ // name: string,
184
+ // timestamp: number
185
+ // }
186
+
187
+ //--------------------------------------------------------------------------------------------
188
+ //
189
+ // ... or use the type to parse JavaScript values.
190
+ //
191
+ //--------------------------------------------------------------------------------------------
192
+
193
+ import { Value } from '@sinclair/typebox/value'
194
+
195
+ const R = Value.Parse(T, value) // const R: {
196
+ // id: string,
197
+ // name: string,
198
+ // timestamp: number
199
+ // }
200
+ ```
201
+
202
+ <a name='types'></a>
203
+
204
+ ## Types
205
+
206
+ TypeBox types are Json Schema fragments that compose into more complex types. Each fragment is structured such that any Json Schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox offers a set of Json Types which are used to create Json Schema compliant schematics as well as a JavaScript type set used to create schematics for constructs native to JavaScript.
207
+
208
+ <a name='types-json'></a>
209
+
210
+ ### Json Types
211
+
212
+ The following table lists the supported Json types. These types are fully compatible with the Json Schema Draft 7 specification.
213
+
214
+ ```typescript
215
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
216
+ │ TypeBox │ TypeScript │ Json Schema │
217
+ │ │ │ │
218
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
219
+ │ const T = Type.Any() │ type T = any │ const T = { } │
220
+ │ │ │ │
221
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
222
+ │ const T = Type.Unknown() │ type T = unknown │ const T = { } │
223
+ │ │ │ │
224
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
225
+ │ const T = Type.String() │ type T = string │ const T = { │
226
+ │ │ │ type: 'string' │
227
+ │ │ │ } │
228
+ │ │ │ │
229
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
230
+ │ const T = Type.Number() │ type T = number │ const T = { │
231
+ │ │ │ type: 'number' │
232
+ │ │ │ } │
233
+ │ │ │ │
234
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
235
+ │ const T = Type.Integer() │ type T = number │ const T = { │
236
+ │ │ │ type: 'integer' │
237
+ │ │ │ } │
238
+ │ │ │ │
239
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
240
+ │ const T = Type.Boolean() │ type T = boolean │ const T = { │
241
+ │ │ │ type: 'boolean' │
242
+ │ │ │ } │
243
+ │ │ │ │
244
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
245
+ │ const T = Type.Null() │ type T = null │ const T = { │
246
+ │ │ │ type: 'null' │
247
+ │ │ │ } │
248
+ │ │ │ │
249
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
250
+ │ const T = Type.Literal(42) │ type T = 42 │ const T = { │
251
+ │ │ │ const: 42, │
252
+ │ │ │ type: 'number' │
253
+ │ │ │ } │
254
+ │ │ │ │
255
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
256
+ │ const T = Type.Array( │ type T = number[] │ const T = { │
257
+ │ Type.Number() │ │ type: 'array', │
258
+ │ ) │ │ items: { │
259
+ │ │ │ type: 'number' │
260
+ │ │ │ } │
261
+ │ │ │ } │
262
+ │ │ │ │
263
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
264
+ │ const T = Type.Object({ │ type T = { │ const T = { │
265
+ │ x: Type.Number(), │ x: number, │ type: 'object', │
266
+ │ y: Type.Number() │ y: number │ required: ['x', 'y'], │
267
+ │ }) │ } │ properties: { │
268
+ │ │ │ x: { │
269
+ │ │ │ type: 'number' │
270
+ │ │ │ }, │
271
+ │ │ │ y: { │
272
+ │ │ │ type: 'number' │
273
+ │ │ │ } │
274
+ │ │ │ } │
275
+ │ │ │ } │
276
+ │ │ │ │
277
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
278
+ │ const T = Type.Tuple([ │ type T = [number, number] │ const T = { │
279
+ │ Type.Number(), │ │ type: 'array', │
280
+ │ Type.Number() │ │ items: [{ │
281
+ │ ]) │ │ type: 'number' │
282
+ │ │ │ }, { │
283
+ │ │ │ type: 'number' │
284
+ │ │ │ }], │
285
+ │ │ │ additionalItems: false, │
286
+ │ │ │ minItems: 2, │
287
+ │ │ │ maxItems: 2 │
288
+ │ │ │ } │
289
+ │ │ │ │
290
+ │ │ │ │
291
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
292
+ │ enum Foo { │ enum Foo { │ const T = { │
293
+ │ A, │ A, │ anyOf: [{ │
294
+ │ B │ B │ type: 'number', │
295
+ │ } │ } │ const: 0 │
296
+ │ │ │ }, { │
297
+ │ const T = Type.Enum(Foo) │ type T = Foo │ type: 'number', │
298
+ │ │ │ const: 1 │
299
+ │ │ │ }] │
300
+ │ │ │ } │
301
+ │ │ │ │
302
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
303
+ │ const T = Type.Const({ │ type T = { │ const T = { │
304
+ │ x: 1, │ readonly x: 1, │ type: 'object', │
305
+ │ y: 2, │ readonly y: 2 │ required: ['x', 'y'], │
306
+ │ } as const) │ } │ properties: { │
307
+ │ │ │ x: { │
308
+ │ │ │ type: 'number', │
309
+ │ │ │ const: 1 │
310
+ │ │ │ }, │
311
+ │ │ │ y: { │
312
+ │ │ │ type: 'number', │
313
+ │ │ │ const: 2 │
314
+ │ │ │ } │
315
+ │ │ │ } │
316
+ │ │ │ } │
317
+ │ │ │ │
318
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
319
+ │ const T = Type.KeyOf( │ type T = keyof { │ const T = { │
320
+ │ Type.Object({ │ x: number, │ anyOf: [{ │
321
+ │ x: Type.Number(), │ y: number │ type: 'string', │
322
+ │ y: Type.Number() │ } │ const: 'x' │
323
+ │ }) │ │ }, { │
324
+ │ ) │ │ type: 'string', │
325
+ │ │ │ const: 'y' │
326
+ │ │ │ }] │
327
+ │ │ │ } │
328
+ │ │ │ │
329
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
330
+ │ const T = Type.Union([ │ type T = string | number │ const T = { │
331
+ │ Type.String(), │ │ anyOf: [{ │
332
+ │ Type.Number() │ │ type: 'string' │
333
+ │ ]) │ │ }, { │
334
+ │ │ │ type: 'number' │
335
+ │ │ │ }] │
336
+ │ │ │ } │
337
+ │ │ │ │
338
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
339
+ │ const T = Type.Intersect([ │ type T = { │ const T = { │
340
+ │ Type.Object({ │ x: number │ allOf: [{ │
341
+ │ x: Type.Number() │ } & { │ type: 'object', │
342
+ │ }), │ y: number │ required: ['x'], │
343
+ │ Type.Object({ │ } │ properties: { │
344
+ │ y: Type.Number() │ │ x: { │
345
+ │ }) │ │ type: 'number' │
346
+ │ ]) │ │ } │
347
+ │ │ │ } │
348
+ │ │ │ }, { │
349
+ │ │ │ type: 'object', |
350
+ │ │ │ required: ['y'], │
351
+ │ │ │ properties: { │
352
+ │ │ │ y: { │
353
+ │ │ │ type: 'number' │
354
+ │ │ │ } │
355
+ │ │ │ } │
356
+ │ │ │ }] │
357
+ │ │ │ } │
358
+ │ │ │ │
359
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
360
+ │ const T = Type.Composite([ │ type T = { │ const T = { │
361
+ │ Type.Object({ │ x: number, │ type: 'object', │
362
+ │ x: Type.Number() │ y: number │ required: ['x', 'y'], │
363
+ │ }), │ } │ properties: { │
364
+ │ Type.Object({ │ │ x: { │
365
+ │ y: Type.Number() │ │ type: 'number' │
366
+ │ }) │ │ }, │
367
+ │ ]) │ │ y: { │
368
+ │ │ │ type: 'number' │
369
+ │ │ │ } │
370
+ │ │ │ } │
371
+ │ │ │ } │
372
+ │ │ │ │
373
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
374
+ │ const T = Type.Never() │ type T = never │ const T = { │
375
+ │ │ │ not: {} │
376
+ │ │ │ } │
377
+ │ │ │ │
378
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
379
+ │ const T = Type.Not( | type T = unknown │ const T = { │
380
+ │ Type.String() │ │ not: { │
381
+ │ ) │ │ type: 'string' │
382
+ │ │ │ } │
383
+ │ │ │ } │
384
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
385
+ │ const T = Type.Extends( │ type T = │ const T = { │
386
+ │ Type.String(), │ string extends number │ const: false, │
387
+ │ Type.Number(), │ ? true │ type: 'boolean' │
388
+ │ Type.Literal(true), │ : false │ } │
389
+ │ Type.Literal(false) │ │ │
390
+ │ ) │ │ │
391
+ │ │ │ │
392
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
393
+ │ const T = Type.Extract( │ type T = Extract< │ const T = { │
394
+ │ Type.Union([ │ string | number, │ type: 'string' │
395
+ │ Type.String(), │ string │ } │
396
+ │ Type.Number(), │ > │ │
397
+ │ ]), │ │ │
398
+ │ Type.String() │ │ │
399
+ │ ) │ │ │
400
+ │ │ │ │
401
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
402
+ │ const T = Type.Exclude( │ type T = Exclude< │ const T = { │
403
+ │ Type.Union([ │ string | number, │ type: 'number' │
404
+ │ Type.String(), │ string │ } │
405
+ │ Type.Number(), │ > │ │
406
+ │ ]), │ │ │
407
+ │ Type.String() │ │ │
408
+ │ ) │ │ │
409
+ │ │ │ │
410
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
411
+ │ const T = Type.Mapped( │ type T = { │ const T = { │
412
+ │ Type.Union([ │ [_ in 'x' | 'y'] : number │ type: 'object', │
413
+ │ Type.Literal('x'), │ } │ required: ['x', 'y'], │
414
+ │ Type.Literal('y') │ │ properties: { │
415
+ │ ]), │ │ x: { │
416
+ │ () => Type.Number() │ │ type: 'number' │
417
+ │ ) │ │ }, │
418
+ │ │ │ y: { │
419
+ │ │ │ type: 'number' │
420
+ │ │ │ } │
421
+ │ │ │ } │
422
+ │ │ │ } │
423
+ │ │ │ │
424
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
425
+ │ const U = Type.Union([ │ type U = 'open' | 'close' │ const T = { │
426
+ │ Type.Literal('open'), │ │ type: 'string', │
427
+ │ Type.Literal('close') │ type T = `on${U}` │ pattern: '^on(open|close)$' │
428
+ │ ]) │ │ } │
429
+ │ │ │ │
430
+ │ const T = Type │ │ │
431
+ │ .TemplateLiteral([ │ │ │
432
+ │ Type.Literal('on'), │ │ │
433
+ │ U │ │ │
434
+ │ ]) │ │ │
435
+ │ │ │ │
436
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
437
+ │ const T = Type.Record( │ type T = Record< │ const T = { │
438
+ │ Type.String(), │ string, │ type: 'object', │
439
+ │ Type.Number() │ number │ patternProperties: { │
440
+ │ ) │ > │ '^.*$': { │
441
+ │ │ │ type: 'number' │
442
+ │ │ │ } │
443
+ │ │ │ } │
444
+ │ │ │ } │
445
+ │ │ │ │
446
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
447
+ │ const T = Type.Partial( │ type T = Partial<{ │ const T = { │
448
+ │ Type.Object({ │ x: number, │ type: 'object', │
449
+ │ x: Type.Number(), │ y: number │ properties: { │
450
+ │ y: Type.Number() | }> │ x: { │
451
+ │ }) │ │ type: 'number' │
452
+ │ ) │ │ }, │
453
+ │ │ │ y: { │
454
+ │ │ │ type: 'number' │
455
+ │ │ │ } │
456
+ │ │ │ } │
457
+ │ │ │ } │
458
+ │ │ │ │
459
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
460
+ │ const T = Type.Required( │ type T = Required<{ │ const T = { │
461
+ │ Type.Object({ │ x?: number, │ type: 'object', │
462
+ │ x: Type.Optional( │ y?: number │ required: ['x', 'y'], │
463
+ │ Type.Number() | }> │ properties: { │
464
+ │ ), │ │ x: { │
465
+ │ y: Type.Optional( │ │ type: 'number' │
466
+ │ Type.Number() │ │ }, │
467
+ │ ) │ │ y: { │
468
+ │ }) │ │ type: 'number' │
469
+ │ ) │ │ } │
470
+ │ │ │ } │
471
+ │ │ │ } │
472
+ │ │ │ │
473
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
474
+ │ const T = Type.Pick( │ type T = Pick<{ │ const T = { │
475
+ │ Type.Object({ │ x: number, │ type: 'object', │
476
+ │ x: Type.Number(), │ y: number │ required: ['x'], │
477
+ │ y: Type.Number() │ }, 'x'> │ properties: { │
478
+ │ }), ['x'] | │ x: { │
479
+ │ ) │ │ type: 'number' │
480
+ │ │ │ } │
481
+ │ │ │ } │
482
+ │ │ │ } │
483
+ │ │ │ │
484
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
485
+ │ const T = Type.Omit( │ type T = Omit<{ │ const T = { │
486
+ │ Type.Object({ │ x: number, │ type: 'object', │
487
+ │ x: Type.Number(), │ y: number │ required: ['y'], │
488
+ │ y: Type.Number() │ }, 'x'> │ properties: { │
489
+ │ }), ['x'] | │ y: { │
490
+ │ ) │ │ type: 'number' │
491
+ │ │ │ } │
492
+ │ │ │ } │
493
+ │ │ │ } │
494
+ │ │ │ │
495
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
496
+ │ const T = Type.Index( │ type T = { │ const T = { │
497
+ │ Type.Object({ │ x: number, │ type: 'number' │
498
+ │ x: Type.Number(), │ y: string │ } │
499
+ │ y: Type.String() │ }['x'] │ │
500
+ │ }), ['x'] │ │ │
501
+ │ ) │ │ │
502
+ │ │ │ │
503
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
504
+ │ const A = Type.Tuple([ │ type A = [0, 1] │ const T = { │
505
+ │ Type.Literal(0), │ type B = [2, 3] │ type: 'array', │
506
+ │ Type.Literal(1) │ type T = [ │ items: [ │
507
+ │ ]) │ ...A, │ { const: 0 }, │
508
+ │ const B = Type.Tuple([ │ ...B │ { const: 1 }, │
509
+ | Type.Literal(2), │ ] │ { const: 2 }, │
510
+ | Type.Literal(3) │ │ { const: 3 } │
511
+ │ ]) │ │ ], │
512
+ │ const T = Type.Tuple([ │ │ additionalItems: false, │
513
+ | ...Type.Rest(A), │ │ minItems: 4, │
514
+ | ...Type.Rest(B) │ │ maxItems: 4 │
515
+ │ ]) │ │ } │
516
+ │ │ │ │
517
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
518
+ │ const T = Type.Uncapitalize( │ type T = Uncapitalize< │ const T = { │
519
+ │ Type.Literal('Hello') │ 'Hello' │ type: 'string', │
520
+ │ ) │ > │ const: 'hello' │
521
+ │ │ │ } │
522
+ │ │ │ │
523
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
524
+ │ const T = Type.Capitalize( │ type T = Capitalize< │ const T = { │
525
+ │ Type.Literal('hello') │ 'hello' │ type: 'string', │
526
+ │ ) │ > │ const: 'Hello' │
527
+ │ │ │ } │
528
+ │ │ │ │
529
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
530
+ │ const T = Type.Uppercase( │ type T = Uppercase< │ const T = { │
531
+ │ Type.Literal('hello') │ 'hello' │ type: 'string', │
532
+ │ ) │ > │ const: 'HELLO' │
533
+ │ │ │ } │
534
+ │ │ │ │
535
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
536
+ │ const T = Type.Lowercase( │ type T = Lowercase< │ const T = { │
537
+ │ Type.Literal('HELLO') │ 'HELLO' │ type: 'string', │
538
+ │ ) │ > │ const: 'hello' │
539
+ │ │ │ } │
540
+ │ │ │ │
541
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
542
+ │ const R = Type.Ref('T') │ type R = unknown │ const R = { $ref: 'T' } │
543
+ │ │ │ │
544
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
545
+ ```
546
+
547
+ <a name='types-javascript'></a>
548
+
549
+ ### JavaScript Types
550
+
551
+ TypeBox provides an extended type set that can be used to create schematics for common JavaScript constructs. These types can not be used with any standard Json Schema validator; but can be used to frame schematics for interfaces that may receive Json validated data. JavaScript types are prefixed with the `[JavaScript]` JSDoc comment for convenience. The following table lists the supported types.
552
+
553
+ ```typescript
554
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
555
+ │ TypeBox │ TypeScript │ Extended Schema │
556
+ │ │ │ │
557
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
558
+ │ const T = Type.Constructor([ │ type T = new ( │ const T = { │
559
+ │ Type.String(), │ arg0: string, │ type: 'Constructor', │
560
+ │ Type.Number() │ arg0: number │ parameters: [{ │
561
+ │ ], Type.Boolean()) │ ) => boolean │ type: 'string' │
562
+ │ │ │ }, { │
563
+ │ │ │ type: 'number' │
564
+ │ │ │ }], │
565
+ │ │ │ returns: { │
566
+ │ │ │ type: 'boolean' │
567
+ │ │ │ } │
568
+ │ │ │ } │
569
+ │ │ │ │
570
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
571
+ │ const T = Type.Function([ │ type T = ( │ const T = { │
572
+ | Type.String(), │ arg0: string, │ type: 'Function', │
573
+ │ Type.Number() │ arg1: number │ parameters: [{ │
574
+ │ ], Type.Boolean()) │ ) => boolean │ type: 'string' │
575
+ │ │ │ }, { │
576
+ │ │ │ type: 'number' │
577
+ │ │ │ }], │
578
+ │ │ │ returns: { │
579
+ │ │ │ type: 'boolean' │
580
+ │ │ │ } │
581
+ │ │ │ } │
582
+ │ │ │ │
583
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
584
+ │ const T = Type.Promise( │ type T = Promise<string> │ const T = { │
585
+ │ Type.String() │ │ type: 'Promise', │
586
+ │ ) │ │ item: { │
587
+ │ │ │ type: 'string' │
588
+ │ │ │ } │
589
+ │ │ │ } │
590
+ │ │ │ │
591
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
592
+ │ const T = │ type T = │ const T = { │
593
+ │ Type.AsyncIterator( │ AsyncIterableIterator< │ type: 'AsyncIterator', │
594
+ │ Type.String() │ string │ items: { │
595
+ │ ) │ > │ type: 'string' │
596
+ │ │ │ } │
597
+ │ │ │ } │
598
+ │ │ │ │
599
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
600
+ │ const T = Type.Iterator( │ type T = │ const T = { │
601
+ │ Type.String() │ IterableIterator<string> │ type: 'Iterator', │
602
+ │ ) │ │ items: { │
603
+ │ │ │ type: 'string' │
604
+ │ │ │ } │
605
+ │ │ │ } │
606
+ │ │ │ │
607
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
608
+ │ const T = Type.RegExp(/abc/i) │ type T = string │ const T = { │
609
+ │ │ │ type: 'RegExp' │
610
+ │ │ │ source: 'abc' │
611
+ │ │ │ flags: 'i' │
612
+ │ │ │ } │
613
+ │ │ │ │
614
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
615
+ │ const T = Type.Uint8Array() │ type T = Uint8Array │ const T = { │
616
+ │ │ │ type: 'Uint8Array' │
617
+ │ │ │ } │
618
+ │ │ │ │
619
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
620
+ │ const T = Type.Date() │ type T = Date │ const T = { │
621
+ │ │ │ type: 'Date' │
622
+ │ │ │ } │
623
+ │ │ │ │
624
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
625
+ │ const T = Type.Undefined() │ type T = undefined │ const T = { │
626
+ │ │ │ type: 'undefined' │
627
+ │ │ │ } │
628
+ │ │ │ │
629
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
630
+ │ const T = Type.Symbol() │ type T = symbol │ const T = { │
631
+ │ │ │ type: 'symbol' │
632
+ │ │ │ } │
633
+ │ │ │ │
634
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
635
+ │ const T = Type.BigInt() │ type T = bigint │ const T = { │
636
+ │ │ │ type: 'bigint' │
637
+ │ │ │ } │
638
+ │ │ │ │
639
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
640
+ │ const T = Type.Void() │ type T = void │ const T = { │
641
+ │ │ │ type: 'void' │
642
+ │ │ │ } │
643
+ │ │ │ │
644
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
645
+ ```
646
+
647
+ <a name='types-options'></a>
648
+
649
+ ### Options
650
+
651
+ You can pass Json Schema options on the last argument of any given type. Option hints specific to each type are provided for convenience.
652
+
653
+ ```typescript
654
+ // String must be an email
655
+ const T = Type.String({ // const T = {
656
+ format: 'email' // type: 'string',
657
+ }) // format: 'email'
658
+ // }
659
+
660
+ // Number must be a multiple of 2
661
+ const T = Type.Number({ // const T = {
662
+ multipleOf: 2 // type: 'number',
663
+ }) // multipleOf: 2
664
+ // }
665
+
666
+ // Array must have at least 5 integer values
667
+ const T = Type.Array(Type.Integer(), { // const T = {
668
+ minItems: 5 // type: 'array',
669
+ }) // minItems: 5,
670
+ // items: {
671
+ // type: 'integer'
672
+ // }
673
+ // }
674
+ ```
675
+
676
+ <a name='types-properties'></a>
677
+
678
+ ### Properties
679
+
680
+ Object properties can be modified with Readonly and Optional. The following table shows how these modifiers map between TypeScript and Json Schema.
681
+
682
+ ```typescript
683
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
684
+ │ TypeBox │ TypeScript │ Json Schema │
685
+ │ │ │ │
686
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
687
+ │ const T = Type.Object({ │ type T = { │ const T = { │
688
+ │ name: Type.ReadonlyOptional( │ readonly name?: string │ type: 'object', │
689
+ │ Type.String() │ } │ properties: { │
690
+ │ ) │ │ name: { │
691
+ │ }) │ │ type: 'string' │
692
+ │ │ │ } │
693
+ │ │ │ } │
694
+ │ │ │ } │
695
+ │ │ │ │
696
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
697
+ │ const T = Type.Object({ │ type T = { │ const T = { │
698
+ │ name: Type.Readonly( │ readonly name: string │ type: 'object', │
699
+ │ Type.String() │ } │ properties: { │
700
+ │ ) │ │ name: { │
701
+ │ }) │ │ type: 'string' │
702
+ │ │ │ } │
703
+ │ │ │ }, │
704
+ │ │ │ required: ['name'] │
705
+ │ │ │ } │
706
+ │ │ │ │
707
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
708
+ │ const T = Type.Object({ │ type T = { │ const T = { │
709
+ │ name: Type.Optional( │ name?: string │ type: 'object', │
710
+ │ Type.String() │ } │ properties: { │
711
+ │ ) │ │ name: { │
712
+ │ }) │ │ type: 'string' │
713
+ │ │ │ } │
714
+ │ │ │ } │
715
+ │ │ │ } │
716
+ │ │ │ │
717
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
718
+ ```
719
+
720
+ <a name='types-generics'></a>
721
+
722
+ ### Generic Types
723
+
724
+ Generic types can be created with generic functions.
725
+
726
+ ```typescript
727
+ const Nullable = <T extends TSchema>(T: T) => { // type Nullable<T> = T | null
728
+ return Type.Union([T, Type.Null()])
729
+ }
730
+
731
+ const T = Nullable(Type.String()) // type T = Nullable<string>
732
+ ```
733
+
734
+ <a name='types-recursive'></a>
735
+
736
+ ### Recursive Types
737
+
738
+ Use the Recursive function to create recursive types.
739
+
740
+ ```typescript
741
+ const Node = Type.Recursive(This => Type.Object({ // const Node = {
742
+ id: Type.String(), // $id: 'Node',
743
+ nodes: Type.Array(This) // type: 'object',
744
+ }), { $id: 'Node' }) // properties: {
745
+ // id: {
746
+ // type: 'string'
747
+ // },
748
+ // nodes: {
749
+ // type: 'array',
750
+ // items: {
751
+ // $ref: 'Node'
752
+ // }
753
+ // }
754
+ // },
755
+ // required: [
756
+ // 'id',
757
+ // 'nodes'
758
+ // ]
759
+ // }
760
+
761
+ type Node = Static<typeof Node> // type Node = {
762
+ // id: string
763
+ // nodes: Node[]
764
+ // }
765
+
766
+ function test(node: Node) {
767
+ const id = node.nodes[0].nodes[0].id // id is string
768
+ }
769
+ ```
770
+
771
+ <a name='types-modules'></a>
772
+
773
+ ### Module Types
774
+
775
+ Module types are containers for a set of referential types. Modules act as namespaces, enabling types to reference one another via string identifiers. Modules support both singular and mutually recursive references, as well as deferred dereferencing for computed types such as Partial. Types imported from a module are expressed using the Json Schema `$defs` keyword.
776
+
777
+ ```typescript
778
+ const Module = Type.Module({
779
+ PartialUser: Type.Partial(Type.Ref('User')), // TComputed<'Partial', [TRef<'User'>]>
780
+
781
+ User: Type.Object({ // TObject<{
782
+ id: Type.String(), // user: TString,
783
+ name: Type.String(), // name: TString,
784
+ email: Type.String() // email: TString
785
+ }), // }>
786
+ })
787
+ const User = Module.Import('User') // const User: TImport<{...}, 'User'>
788
+
789
+ type User = Static<typeof User> // type User = {
790
+ // id: string,
791
+ // name: string,
792
+ // email: string
793
+ // }
794
+
795
+ const PartialUser = Module.Import('PartialUser') // const PartialUser: TImport<{...}, 'PartialUser'>
796
+
797
+ type PartialUser = Static<typeof PartialUser> // type PartialUser = {
798
+ // id?: string,
799
+ // name?: string,
800
+ // email?: string
801
+ // }
802
+ ```
803
+
804
+ <a name='types-template-literal'></a>
805
+
806
+ ### Template Literal Types
807
+
808
+ TypeBox supports template literal types with the TemplateLiteral function. This type can be created using a syntax similar to the TypeScript template literal syntax or composed from exterior types. TypeBox encodes template literals as regular expressions which enables the template to be checked by Json Schema validators. This type also supports regular expression parsing that enables template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.
809
+
810
+ ```typescript
811
+ // TypeScript
812
+
813
+ type K = `prop${'A'|'B'|'C'}` // type T = 'propA' | 'propB' | 'propC'
814
+
815
+ type R = Record<K, string> // type R = {
816
+ // propA: string
817
+ // propB: string
818
+ // propC: string
819
+ // }
820
+
821
+ // TypeBox
822
+
823
+ const K = Type.TemplateLiteral('prop${A|B|C}') // const K: TTemplateLiteral<[
824
+ // TLiteral<'prop'>,
825
+ // TUnion<[
826
+ // TLiteral<'A'>,
827
+ // TLiteral<'B'>,
828
+ // TLiteral<'C'>,
829
+ // ]>
830
+ // ]>
831
+
832
+ const R = Type.Record(K, Type.String()) // const R: TObject<{
833
+ // propA: TString,
834
+ // propB: TString,
835
+ // propC: TString,
836
+ // }>
837
+ ```
838
+
839
+ <a name='types-indexed'></a>
840
+
841
+ ### Indexed Access Types
842
+
843
+ TypeBox supports indexed access types with the Index function. This function enables uniform access to interior property and element types without having to extract them from the underlying schema representation. Index types are supported for Object, Array, Tuple, Union and Intersect types.
844
+
845
+ ```typescript
846
+ const T = Type.Object({ // type T = {
847
+ x: Type.Number(), // x: number,
848
+ y: Type.String(), // y: string,
849
+ z: Type.Boolean() // z: boolean
850
+ }) // }
851
+
852
+ const A = Type.Index(T, ['x']) // type A = T['x']
853
+ //
854
+ // ... evaluated as
855
+ //
856
+ // const A: TNumber
857
+
858
+ const B = Type.Index(T, ['x', 'y']) // type B = T['x' | 'y']
859
+ //
860
+ // ... evaluated as
861
+ //
862
+ // const B: TUnion<[
863
+ // TNumber,
864
+ // TString,
865
+ // ]>
866
+
867
+ const C = Type.Index(T, Type.KeyOf(T)) // type C = T[keyof T]
868
+ //
869
+ // ... evaluated as
870
+ //
871
+ // const C: TUnion<[
872
+ // TNumber,
873
+ // TString,
874
+ // TBoolean
875
+ // ]>
876
+ ```
877
+
878
+ <a name='types-mapped'></a>
879
+
880
+ ### Mapped Types
881
+
882
+ TypeBox supports mapped types with the Mapped function. This function accepts two arguments, the first is a union type typically derived from KeyOf, the second is a mapping function that receives a mapping key `K` that can be used to index properties of a type. The following implements a mapped type that remaps each property to be `T | null`.
883
+
884
+ ```typescript
885
+ const T = Type.Object({ // type T = {
886
+ x: Type.Number(), // x: number,
887
+ y: Type.String(), // y: string,
888
+ z: Type.Boolean() // z: boolean
889
+ }) // }
890
+
891
+ const M = Type.Mapped(Type.KeyOf(T), K => { // type M = { [K in keyof T]: T[K] | null }
892
+ return Type.Union([Type.Index(T, K), Type.Null()]) //
893
+ }) // ... evaluated as
894
+ //
895
+ // const M: TObject<{
896
+ // x: TUnion<[TNumber, TNull]>,
897
+ // y: TUnion<[TString, TNull]>,
898
+ // z: TUnion<[TBoolean, TNull]>
899
+ // }>
900
+ ```
901
+
902
+ <a name='types-conditional'></a>
903
+
904
+ ### Conditional Types
905
+
906
+ TypeBox supports runtime conditional types with the Extends function. This function performs a structural assignability check against the first (`left`) and second (`right`) arguments and will return either the third (`true`) or fourth (`false`) argument based on the result. The conditional types Exclude and Extract are also supported. The following shows both TypeScript and TypeBox examples of conditional types.
907
+
908
+ ```typescript
909
+ // Extends
910
+ const A = Type.Extends( // type A = string extends number ? 1 : 2
911
+ Type.String(), //
912
+ Type.Number(), // ... evaluated as
913
+ Type.Literal(1), //
914
+ Type.Literal(2) // const A: TLiteral<2>
915
+ )
916
+
917
+ // Extract
918
+ const B = Type.Extract( // type B = Extract<1 | 2 | 3, 1>
919
+ Type.Union([ //
920
+ Type.Literal(1), // ... evaluated as
921
+ Type.Literal(2), //
922
+ Type.Literal(3) // const B: TLiteral<1>
923
+ ]),
924
+ Type.Literal(1)
925
+ )
926
+
927
+ // Exclude
928
+ const C = Type.Exclude( // type C = Exclude<1 | 2 | 3, 1>
929
+ Type.Union([ //
930
+ Type.Literal(1), // ... evaluated as
931
+ Type.Literal(2), //
932
+ Type.Literal(3) // const C: TUnion<[
933
+ ]), // TLiteral<2>,
934
+ Type.Literal(1) // TLiteral<3>,
935
+ ) // ]>
936
+ ```
937
+
938
+ <a name='types-transform'></a>
939
+
940
+ ### Transform Types
941
+
942
+ TypeBox supports value decoding and encoding with Transform types. These types work in tandem with the Encode and Decode functions available on the Value and TypeCompiler submodules. Transform types can be used to convert Json encoded values into constructs more natural to JavaScript. The following creates a Transform type to decode numbers into Dates using the Value submodule.
943
+
944
+ ```typescript
945
+ import { Value } from '@sinclair/typebox/value'
946
+
947
+ const T = Type.Transform(Type.Number())
948
+ .Decode(value => new Date(value)) // decode: number to Date
949
+ .Encode(value => value.getTime()) // encode: Date to number
950
+
951
+ const D = Value.Decode(T, 0) // const D = Date(1970-01-01T00:00:00.000Z)
952
+ const E = Value.Encode(T, D) // const E = 0
953
+ ```
954
+ Use the StaticEncode or StaticDecode types to infer a Transform type.
955
+ ```typescript
956
+ import { Static, StaticDecode, StaticEncode } from '@sinclair/typebox'
957
+
958
+ const T = Type.Transform(Type.Array(Type.Number(), { uniqueItems: true }))
959
+ .Decode(value => new Set(value))
960
+ .Encode(value => [...value])
961
+
962
+ type D = StaticDecode<typeof T> // type D = Set<number>
963
+ type E = StaticEncode<typeof T> // type E = Array<number>
964
+ type T = Static<typeof T> // type T = Array<number>
965
+ ```
966
+
967
+ <a name='types-unsafe'></a>
968
+
969
+ ### Unsafe Types
970
+
971
+ TypeBox supports user defined types with Unsafe. This type allows you to specify both schema representation and inference type. The following creates an Unsafe type with a number schema that infers as string.
972
+
973
+ ```typescript
974
+ const T = Type.Unsafe<string>({ type: 'number' }) // const T = { type: 'number' }
975
+
976
+ type T = Static<typeof T> // type T = string - ?
977
+ ```
978
+ The Unsafe type is often used to create schematics for extended specifications like OpenAPI.
979
+ ```typescript
980
+
981
+ const Nullable = <T extends TSchema>(schema: T) => Type.Unsafe<Static<T> | null>({
982
+ ...schema, nullable: true
983
+ })
984
+
985
+ const T = Nullable(Type.String()) // const T = {
986
+ // type: 'string',
987
+ // nullable: true
988
+ // }
989
+
990
+ type T = Static<typeof T> // type T = string | null
991
+
992
+ const StringEnum = <T extends string[]>(values: [...T]) => Type.Unsafe<T[number]>({
993
+ type: 'string', enum: values
994
+ })
995
+ const S = StringEnum(['A', 'B', 'C']) // const S = {
996
+ // enum: ['A', 'B', 'C']
997
+ // }
998
+
999
+ type S = Static<typeof T> // type S = 'A' | 'B' | 'C'
1000
+ ```
1001
+ <a name='types-guard'></a>
1002
+
1003
+ ### TypeGuard
1004
+
1005
+ TypeBox can check its own types with the TypeGuard module. This module is written for type introspection and provides structural tests for every built-in TypeBox type. Functions of this module return `is` guards which can be used with control flow assertions to obtain schema inference for unknown values. The following guards that the value `T` is TString.
1006
+
1007
+ ```typescript
1008
+ import { TypeGuard, Kind } from '@sinclair/typebox'
1009
+
1010
+ const T = { [Kind]: 'String', type: 'string' }
1011
+
1012
+ if(TypeGuard.IsString(T)) {
1013
+
1014
+ // T is TString
1015
+ }
1016
+ ```
1017
+
1018
+ <a name='values'></a>
1019
+
1020
+ ## Values
1021
+
1022
+ TypeBox provides an optional Value submodule that can be used to perform structural operations on JavaScript values. This submodule includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This submodule is provided via optional import.
1023
+
1024
+ ```typescript
1025
+ import { Value } from '@sinclair/typebox/value'
1026
+ ```
1027
+
1028
+ <a name='values-assert'></a>
1029
+
1030
+ ### Assert
1031
+
1032
+ Use the Assert function to assert a value is valid.
1033
+
1034
+ ```typescript
1035
+ let value: unknown = 1
1036
+
1037
+ Value.Assert(Type.Number(), value) // throws AssertError if invalid
1038
+ ```
1039
+
1040
+ <a name='values-create'></a>
1041
+
1042
+ ### Create
1043
+
1044
+ Use the Create function to create a value from a type. TypeBox will use default values if specified.
1045
+
1046
+ ```typescript
1047
+ const T = Type.Object({ x: Type.Number(), y: Type.Number({ default: 42 }) })
1048
+
1049
+ const A = Value.Create(T) // const A = { x: 0, y: 42 }
1050
+ ```
1051
+
1052
+ <a name='values-clone'></a>
1053
+
1054
+ ### Clone
1055
+
1056
+ Use the Clone function to deeply clone a value.
1057
+
1058
+ ```typescript
1059
+ const A = Value.Clone({ x: 1, y: 2, z: 3 }) // const A = { x: 1, y: 2, z: 3 }
1060
+ ```
1061
+
1062
+ <a name='values-check'></a>
1063
+
1064
+ ### Check
1065
+
1066
+ Use the Check function to type check a value.
1067
+
1068
+ ```typescript
1069
+ const T = Type.Object({ x: Type.Number() })
1070
+
1071
+ const R = Value.Check(T, { x: 1 }) // const R = true
1072
+ ```
1073
+
1074
+ <a name='values-convert'></a>
1075
+
1076
+ ### Convert
1077
+
1078
+ Use the Convert function to convert a value into its target type if a reasonable conversion is possible. This function may return an invalid value and should be checked before use. Its return type is `unknown`.
1079
+
1080
+ ```typescript
1081
+ const T = Type.Object({ x: Type.Number() })
1082
+
1083
+ const R1 = Value.Convert(T, { x: '3.14' }) // const R1 = { x: 3.14 }
1084
+
1085
+ const R2 = Value.Convert(T, { x: 'not a number' }) // const R2 = { x: 'not a number' }
1086
+ ```
1087
+
1088
+ <a name='values-clean'></a>
1089
+
1090
+ ### Clean
1091
+
1092
+ Use Clean to remove excess properties from a value. This function does not check the value and returns an unknown type. You should Check the result before use. Clean is a mutable operation. To avoid mutation, Clone the value first.
1093
+
1094
+ ```typescript
1095
+ const T = Type.Object({
1096
+ x: Type.Number(),
1097
+ y: Type.Number()
1098
+ })
1099
+
1100
+ const X = Value.Clean(T, null) // const 'X = null
1101
+
1102
+ const Y = Value.Clean(T, { x: 1 }) // const 'Y = { x: 1 }
1103
+
1104
+ const Z = Value.Clean(T, { x: 1, y: 2, z: 3 }) // const 'Z = { x: 1, y: 2 }
1105
+ ```
1106
+
1107
+ <a name='values-default'></a>
1108
+
1109
+ ### Default
1110
+
1111
+ Use Default to generate missing properties on a value using default schema annotations if available. This function does not check the value and returns an unknown type. You should Check the result before use. Default is a mutable operation. To avoid mutation, Clone the value first.
1112
+
1113
+ ```typescript
1114
+ const T = Type.Object({
1115
+ x: Type.Number({ default: 0 }),
1116
+ y: Type.Number({ default: 0 })
1117
+ })
1118
+
1119
+ const X = Value.Default(T, null) // const 'X = null - non-enumerable
1120
+
1121
+ const Y = Value.Default(T, { }) // const 'Y = { x: 0, y: 0 }
1122
+
1123
+ const Z = Value.Default(T, { x: 1 }) // const 'Z = { x: 1, y: 0 }
1124
+ ```
1125
+
1126
+ <a name='values-cast'></a>
1127
+
1128
+ ### Cast
1129
+
1130
+ Use the Cast function to upcast a value into a target type. This function will retain as much information as possible from the original value. The Cast function is intended to be used in data migration scenarios where existing values need to be upgraded to match a modified type.
1131
+
1132
+ ```typescript
1133
+ const T = Type.Object({ x: Type.Number(), y: Type.Number() }, { additionalProperties: false })
1134
+
1135
+ const X = Value.Cast(T, null) // const X = { x: 0, y: 0 }
1136
+
1137
+ const Y = Value.Cast(T, { x: 1 }) // const Y = { x: 1, y: 0 }
1138
+
1139
+ const Z = Value.Cast(T, { x: 1, y: 2, z: 3 }) // const Z = { x: 1, y: 2 }
1140
+ ```
1141
+
1142
+ <a name='values-decode'></a>
1143
+
1144
+ ### Decode
1145
+
1146
+ Use the Decode function to decode a value from a type or throw if the value is invalid. The return value will infer as the decoded type. This function will run Transform codecs if available.
1147
+
1148
+ ```typescript
1149
+ const A = Value.Decode(Type.String(), 'hello') // const A = 'hello'
1150
+
1151
+ const B = Value.Decode(Type.String(), 42) // throw
1152
+ ```
1153
+ <a name='values-decode'></a>
1154
+
1155
+ ### Encode
1156
+
1157
+ Use the Encode function to encode a value to a type or throw if the value is invalid. The return value will infer as the encoded type. This function will run Transform codecs if available.
1158
+
1159
+ ```typescript
1160
+ const A = Value.Encode(Type.String(), 'hello') // const A = 'hello'
1161
+
1162
+ const B = Value.Encode(Type.String(), 42) // throw
1163
+ ```
1164
+
1165
+ <a name='values-parse'></a>
1166
+
1167
+ ### Parse
1168
+
1169
+ Use the Parse function to parse a value. This function calls the `Clone` `Clean`, `Default`, `Convert`, `Assert` and `Decode` Value functions in this exact order to process a value.
1170
+
1171
+ ```typescript
1172
+ const R = Value.Parse(Type.String(), 'hello') // const R: string = "hello"
1173
+
1174
+ const E = Value.Parse(Type.String(), undefined) // throws AssertError
1175
+ ```
1176
+
1177
+ You can override the order in which functions are run, or omit functions entirely using the following.
1178
+
1179
+ ```typescript
1180
+ // Runs no functions.
1181
+
1182
+ const R = Value.Parse([], Type.String(), 12345)
1183
+
1184
+ // Runs the Assert() function.
1185
+
1186
+ const E = Value.Parse(['Assert'], Type.String(), 12345)
1187
+
1188
+ // Runs the Convert() function followed by the Assert() function.
1189
+
1190
+ const S = Value.Parse(['Convert', 'Assert'], Type.String(), 12345)
1191
+ ```
1192
+
1193
+ <a name='values-equal'></a>
1194
+
1195
+ ### Equal
1196
+
1197
+ Use the Equal function to deeply check for value equality.
1198
+
1199
+ ```typescript
1200
+ const R = Value.Equal( // const R = true
1201
+ { x: 1, y: 2, z: 3 },
1202
+ { x: 1, y: 2, z: 3 }
1203
+ )
1204
+ ```
1205
+
1206
+ <a name='values-hash'></a>
1207
+
1208
+ ### Hash
1209
+
1210
+ Use the Hash function to create a [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash of a value.
1211
+
1212
+ ```typescript
1213
+ const A = Value.Hash({ x: 1, y: 2, z: 3 }) // const A = 2910466848807138541n
1214
+
1215
+ const B = Value.Hash({ x: 1, y: 4, z: 3 }) // const B = 1418369778807423581n
1216
+ ```
1217
+
1218
+ <a name='values-diff'></a>
1219
+
1220
+ ### Diff
1221
+
1222
+ Use the Diff function to generate a sequence of edits that will transform one value into another.
1223
+
1224
+ ```typescript
1225
+ const E = Value.Diff( // const E = [
1226
+ { x: 1, y: 2, z: 3 }, // { type: 'update', path: '/y', value: 4 },
1227
+ { y: 4, z: 5, w: 6 } // { type: 'update', path: '/z', value: 5 },
1228
+ ) // { type: 'insert', path: '/w', value: 6 },
1229
+ // { type: 'delete', path: '/x' }
1230
+ // ]
1231
+ ```
1232
+
1233
+ <a name='values-patch'></a>
1234
+
1235
+ ### Patch
1236
+
1237
+ Use the Patch function to apply a sequence of edits.
1238
+
1239
+ ```typescript
1240
+ const A = { x: 1, y: 2 }
1241
+
1242
+ const B = { x: 3 }
1243
+
1244
+ const E = Value.Diff(A, B) // const E = [
1245
+ // { type: 'update', path: '/x', value: 3 },
1246
+ // { type: 'delete', path: '/y' }
1247
+ // ]
1248
+
1249
+ const C = Value.Patch<typeof B>(A, E) // const C = { x: 3 }
1250
+ ```
1251
+
1252
+ <a name='values-errors'></a>
1253
+
1254
+ ### Errors
1255
+
1256
+ Use the Errors function to enumerate validation errors.
1257
+
1258
+ ```typescript
1259
+ const T = Type.Object({ x: Type.Number(), y: Type.Number() })
1260
+
1261
+ const R = [...Value.Errors(T, { x: '42' })] // const R = [{
1262
+ // schema: { type: 'number' },
1263
+ // path: '/x',
1264
+ // value: '42',
1265
+ // message: 'Expected number'
1266
+ // }, {
1267
+ // schema: { type: 'number' },
1268
+ // path: '/y',
1269
+ // value: undefined,
1270
+ // message: 'Expected number'
1271
+ // }]
1272
+ ```
1273
+
1274
+ <a name='values-mutate'></a>
1275
+
1276
+ ### Mutate
1277
+
1278
+ Use the Mutate function to perform a deep mutable value assignment while retaining internal references.
1279
+
1280
+ ```typescript
1281
+ const Y = { z: 1 } // const Y = { z: 1 }
1282
+ const X = { y: Y } // const X = { y: { z: 1 } }
1283
+ const A = { x: X } // const A = { x: { y: { z: 1 } } }
1284
+
1285
+ Value.Mutate(A, { x: { y: { z: 2 } } }) // A' = { x: { y: { z: 2 } } }
1286
+
1287
+ const R0 = A.x.y.z === 2 // const R0 = true
1288
+ const R1 = A.x.y === Y // const R1 = true
1289
+ const R2 = A.x === X // const R2 = true
1290
+ ```
1291
+
1292
+ <a name='values-pointer'></a>
1293
+
1294
+ ### Pointer
1295
+
1296
+ Use ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) Json Pointers.
1297
+
1298
+ ```typescript
1299
+ import { ValuePointer } from '@sinclair/typebox/value'
1300
+
1301
+ const A = { x: 0, y: 0, z: 0 }
1302
+
1303
+ ValuePointer.Set(A, '/x', 1) // A' = { x: 1, y: 0, z: 0 }
1304
+ ValuePointer.Set(A, '/y', 1) // A' = { x: 1, y: 1, z: 0 }
1305
+ ValuePointer.Set(A, '/z', 1) // A' = { x: 1, y: 1, z: 1 }
1306
+ ```
1307
+
1308
+
1309
+
1310
+ <a name='syntax'></a>
1311
+
1312
+ ## Syntax Types
1313
+
1314
+ TypeBox provides experimental support for parsing TypeScript annotation syntax into TypeBox types.
1315
+
1316
+ This feature is provided via optional import.
1317
+
1318
+ ```typescript
1319
+ import { Syntax } from '@sinclair/typebox/syntax'
1320
+ ```
1321
+
1322
+ <a name='syntax-create'></a>
1323
+
1324
+ ### Create
1325
+
1326
+ Use the Syntax function to create TypeBox types from TypeScript syntax ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgChQkWIhTYYwBgWKly1OoxZtO3foMkSGEdDXgAVOAF4Uo3AAoABkhwAuOOgCuIPjygAaOFR3Lx8-AkcASjgY2Jj2djhjUwt3cwB5PgArHgYYAB4ECTiS0rLyisrYhNi3OHMAOW9fAOKq9o7OuBqY4PqmsKg2rpHR+MT8AD4JCS5eeut5LEUGfLmeCCJ6ybHKmvWFmyLdk86euDrQlv9h07uy876rv1v7t-GCIA))
1327
+
1328
+ ```typescript
1329
+ const T = Syntax(`{ x: number, y: number }`) // const T: TObject<{
1330
+ // x: TNumber,
1331
+ // y: TNumber
1332
+ // }>
1333
+
1334
+ type T = Static<typeof T> // type T = {
1335
+ // x: number,
1336
+ // y: number
1337
+ // }
1338
+ ```
1339
+
1340
+ <a name="syntax-parameters"></a>
1341
+
1342
+ ### Parameters
1343
+
1344
+ Syntax types can be parameterized to receive exterior types ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgCgJDCOhrwAKnAC8KUbgAUAAyQ4AXHHQBXEHx5QANHFQHjp8wS0BKOK7ev27ODLmKDCgHk+ACseBhgAHgQJd1i4+ITEpLdPN304BQA5EzNLGOSCwqK4VNcbDOz7KHzi2rqPL3wAPikfeRQVNUxNJCV8Ky0ABSxYYCwmCIUm52LUtvhkfyDQ8Kia+o2C0rh0wLAYYFlxycrcpot1zav47fK9g6OJrJzzFuv3m8amoA))
1345
+
1346
+ ```typescript
1347
+ const T = Syntax(`{ x: number, y: number }`) // const T: TObject<{
1348
+ // x: TNumber,
1349
+ // y: TNumber
1350
+ // }>
1351
+
1352
+ const S = Syntax({ T }, `Partial<T>`) // const S: TObject<{
1353
+ // x: TOptional<TNumber>,
1354
+ // y: TOptional<TNumber>
1355
+ // }>
1356
+ ```
1357
+
1358
+
1359
+
1360
+ <a name="syntax-generics"></a>
1361
+
1362
+ ### Generics
1363
+
1364
+ Syntax types support generic parameters in the following way ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgZQJ4DsYEMAecC+cAZlBCHAOQACAzsOgMYA2WwUA9DKmAKYBGEHOxoZsOCgChQkWIhTYYwBgWKly1OoxZtO3foMkSGEdDXgA1HgxjQ4AXhSjcACgAGAHgAaAGjgBNXwAtAD45CTg4HAAuOB84cLhUGID4iIAvGMD4-FcASgkjEzM4ACEsOhpLa2gae0dMFyQqmygCX1cEBOi4Zuh3AEZfAAZh4O8EpJ6rFvcRuEG4IbGEjKnqqFnh337lnPyJLl5S8uBK6Zq65AUld0OeCCJjit6oGlCIiPZ2ODun05fag5Oh8QaCweCIZCoV8Pt0kN0FpM5qshm0ElCMZisSCYRFJvCYnNJgsUWjseSKeDcXBVgTFr4kb5Vv0COjKezsTD8EA))
1365
+
1366
+ ```typescript
1367
+ const Vector = Syntax(`<X, Y, Z> {
1368
+ x: X,
1369
+ y: Y,
1370
+ z: Z
1371
+ }`)
1372
+
1373
+ const BasisVectors = Syntax({ Vector }, `{
1374
+ x: Vector<1, 0, 0>,
1375
+ y: Vector<0, 1, 0>,
1376
+ z: Vector<0, 0, 1>,
1377
+ }`)
1378
+
1379
+ type BasisVectors = Static<typeof BasisVectors> // type BasisVectors = {
1380
+ // x: { x: 1, y: 0, z: 0 },
1381
+ // y: { x: 0, y: 1, z: 0 },
1382
+ // z: { x: 0, y: 0, z: 1 }
1383
+ // }
1384
+ ```
1385
+
1386
+ <a name='syntax-options'></a>
1387
+
1388
+ ### Options
1389
+
1390
+ Options can be passed via the last parameter.
1391
+
1392
+ ```typescript
1393
+ const T = Syntax(`number`, { minimum: 42 }) // const T = {
1394
+ // type: 'number',
1395
+ // minimum: 42
1396
+ // }
1397
+ ```
1398
+
1399
+ <a name='syntax-no-infer'></a>
1400
+
1401
+ ### NoInfer
1402
+
1403
+ Syntax parsing is an expensive type level operation and can impact on language service performance. Use the NoInfer function parse syntax at runtime only.
1404
+
1405
+ ```typescript
1406
+ import { NoInfer } from '@sinclair/typebox/syntax'
1407
+
1408
+ const T = NoInfer(`number | string`) // const T: TSchema = {
1409
+ // anyOf: [
1410
+ // { type: 'number' },
1411
+ // { type: 'string' }
1412
+ // ]
1413
+ // }
1414
+ ```
1415
+
1416
+ <a name='typeregistry'></a>
1417
+
1418
+ ## TypeRegistry
1419
+
1420
+ The TypeBox type system can be extended with additional types and formats using the TypeRegistry and FormatRegistry modules. These modules integrate deeply with TypeBox's internal type checking infrastructure and can be used to create application specific types, or register schematics for alternative specifications.
1421
+
1422
+ <a name='typeregistry-type'></a>
1423
+
1424
+ ### TypeRegistry
1425
+
1426
+ Use the TypeRegistry to register a type. The Kind must match the registered type name.
1427
+
1428
+ ```typescript
1429
+ import { TSchema, Kind, TypeRegistry } from '@sinclair/typebox'
1430
+
1431
+ TypeRegistry.Set('Foo', (schema, value) => value === 'foo')
1432
+
1433
+ const Foo = { [Kind]: 'Foo' } as TSchema
1434
+
1435
+ const A = Value.Check(Foo, 'foo') // const A = true
1436
+
1437
+ const B = Value.Check(Foo, 'bar') // const B = false
1438
+ ```
1439
+
1440
+ <a name='typeregistry-format'></a>
1441
+
1442
+ ### FormatRegistry
1443
+
1444
+ Use the FormatRegistry to register a string format.
1445
+
1446
+ ```typescript
1447
+ import { FormatRegistry } from '@sinclair/typebox'
1448
+
1449
+ FormatRegistry.Set('foo', (value) => value === 'foo')
1450
+
1451
+ const T = Type.String({ format: 'foo' })
1452
+
1453
+ const A = Value.Check(T, 'foo') // const A = true
1454
+
1455
+ const B = Value.Check(T, 'bar') // const B = false
1456
+ ```
1457
+
1458
+ <a name='typecheck'></a>
1459
+
1460
+ ## TypeCheck
1461
+
1462
+ TypeBox types target Json Schema Draft 7 and are compatible with any validator that supports this specification. TypeBox also provides a built-in type checking compiler designed specifically for TypeBox types that offers high performance compilation and value checking.
1463
+
1464
+ The following sections detail using Ajv and the TypeBox compiler infrastructure.
1465
+
1466
+ <a name='typecheck-ajv'></a>
1467
+
1468
+ ## Ajv
1469
+
1470
+ The following shows the recommended setup for Ajv.
1471
+
1472
+ ```bash
1473
+ $ npm install ajv ajv-formats --save
1474
+ ```
1475
+
1476
+ ```typescript
1477
+ import { Type } from '@sinclair/typebox'
1478
+ import addFormats from 'ajv-formats'
1479
+ import Ajv from 'ajv'
1480
+
1481
+ const ajv = addFormats(new Ajv({}), [
1482
+ 'date-time',
1483
+ 'time',
1484
+ 'date',
1485
+ 'email',
1486
+ 'hostname',
1487
+ 'ipv4',
1488
+ 'ipv6',
1489
+ 'uri',
1490
+ 'uri-reference',
1491
+ 'uuid',
1492
+ 'uri-template',
1493
+ 'json-pointer',
1494
+ 'relative-json-pointer',
1495
+ 'regex'
1496
+ ])
1497
+
1498
+ const validate = ajv.compile(Type.Object({
1499
+ x: Type.Number(),
1500
+ y: Type.Number(),
1501
+ z: Type.Number()
1502
+ }))
1503
+
1504
+ const R = validate({ x: 1, y: 2, z: 3 }) // const R = true
1505
+ ```
1506
+
1507
+ <a name='typecheck-typecompiler'></a>
1508
+
1509
+ ### TypeCompiler
1510
+
1511
+ The TypeBox TypeCompiler is a high performance JIT validation compiler that transforms TypeBox types into optimized JavaScript validation routines. The compiler is tuned for fast compilation as well as fast value assertion. It is built to serve as a validation backend that can be integrated into larger applications. It can also be used for code generation.
1512
+
1513
+ The TypeCompiler is provided as an optional import.
1514
+
1515
+ ```typescript
1516
+ import { TypeCompiler } from '@sinclair/typebox/compiler'
1517
+ ```
1518
+
1519
+ Use the Compile function to JIT compile a type. Note that compilation is generally an expensive operation and should only be performed once per type during application start up. TypeBox does not cache previously compiled types, and applications are expected to hold references to each compiled type for the lifetime of the application.
1520
+
1521
+ ```typescript
1522
+ const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
1523
+ x: Type.Number(), // x: TNumber;
1524
+ y: Type.Number(), // y: TNumber;
1525
+ z: Type.Number() // z: TNumber;
1526
+ })) // }>>
1527
+
1528
+ const R = C.Check({ x: 1, y: 2, z: 3 }) // const R = true
1529
+ ```
1530
+
1531
+ Use the Errors function to generate diagnostic errors for a value. The Errors function will return an iterator that when enumerated; will perform an exhaustive check across the entire value yielding any error found. For performance, this function should only be called after a failed Check. Applications may also choose to yield only the first value to avoid exhaustive error generation.
1532
+
1533
+ ```typescript
1534
+ const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
1535
+ x: Type.Number(), // x: TNumber;
1536
+ y: Type.Number(), // y: TNumber;
1537
+ z: Type.Number() // z: TNumber;
1538
+ })) // }>>
1539
+
1540
+ const value = { }
1541
+
1542
+ const first = C.Errors(value).First() // const first = {
1543
+ // schema: { type: 'number' },
1544
+ // path: '/x',
1545
+ // value: undefined,
1546
+ // message: 'Expected number'
1547
+ // }
1548
+
1549
+ const all = [...C.Errors(value)] // const all = [{
1550
+ // schema: { type: 'number' },
1551
+ // path: '/x',
1552
+ // value: undefined,
1553
+ // message: 'Expected number'
1554
+ // }, {
1555
+ // schema: { type: 'number' },
1556
+ // path: '/y',
1557
+ // value: undefined,
1558
+ // message: 'Expected number'
1559
+ // }, {
1560
+ // schema: { type: 'number' },
1561
+ // path: '/z',
1562
+ // value: undefined,
1563
+ // message: 'Expected number'
1564
+ // }]
1565
+ ```
1566
+
1567
+ Use the Code function to generate assertion functions as strings. This function can be used to generate code that can be written to disk as importable modules. This technique is sometimes referred to as Ahead of Time (AOT) compilation. The following generates code to check a string.
1568
+
1569
+ ```typescript
1570
+ const C = TypeCompiler.Code(Type.String()) // const C = `return function check(value) {
1571
+ // return (
1572
+ // (typeof value === 'string')
1573
+ // )
1574
+ // }`
1575
+ ```
1576
+
1577
+ <a name='typemap'></a>
1578
+
1579
+ ## TypeMap
1580
+
1581
+ TypeBox offers an external package for bidirectional mapping between TypeBox, Valibot, and Zod type libraries. It also includes syntax parsing support for Valibot and Zod and supports the Standard Schema specification. For more details on TypeMap, refer to the project repository.
1582
+
1583
+ [TypeMap Repository](https://github.com/sinclairzx81/typemap)
1584
+
1585
+ <a name='typemap-usage'></a>
1586
+
1587
+ ### Usage
1588
+
1589
+ TypeMap needs to be installed separately
1590
+
1591
+ ```bash
1592
+ $ npm install @sinclair/typemap
1593
+ ```
1594
+
1595
+ Once installed it offers advanced structural remapping between various runtime type libraries ([Example](https://www.typescriptlang.org/play/?moduleResolution=99&module=199&ts=5.8.0-beta#code/JYWwDg9gTgLgBAbzgFQJ5gKYCEIA8A0cAyqgHYwCGBcAWhACZwC+cAZlBCHAOQACAzsFIBjADYVgUAPQx0GEBTDcAUMuERS-eMjgBeFHJy4AFAAMkuAFxxSAVxAAjDFEKprdx88IAvd-adQzKYAlHBwUlJw6pra1sgA8g4AVhjCMAA8CMphObl5+QWFRcW5ETlWKABy-s4A3NkljU3NBWVhblU1UPUtvX3FbXC+nZ7dDf0TE2VMAHyq0VrEesRklCbIoS1lC-BE1twWfqOuRwE+p87MKmoaiwBKy3T0xkTBAHRgFFD8GMZ2oqJNnltrd4HdrFlJltImEKh4Aj0oU1Bh14XVxkiBjChhcxpjGtMwkA))
1596
+
1597
+ ```typescript
1598
+ import { TypeBox, Syntax, Zod } from '@sinclair/typemap'
1599
+
1600
+ const T = TypeBox(`{ x: number, y: number, z: number }`) // const T: TObject<{
1601
+ // x: TNumber;
1602
+ // y: TNumber;
1603
+ // z: TNumber;
1604
+ // }>
1605
+
1606
+ const S = Syntax(T) // const S: '{ x: number, y: number, z: number }'
1607
+
1608
+ const R = Zod(S).parse(null) // const R: {
1609
+ // x: number;
1610
+ // y: number;
1611
+ // z: number;
1612
+ // }
1613
+ ```
1614
+
1615
+ <a name='typesystem'></a>
1616
+
1617
+ ## TypeSystem
1618
+
1619
+ The TypeBox TypeSystem module provides configurations to use either Json Schema or TypeScript type checking semantics. Configurations made to the TypeSystem module are observed by the TypeCompiler, Value and Error modules.
1620
+
1621
+ <a name='typesystem-policies'></a>
1622
+
1623
+ ### Policies
1624
+
1625
+ TypeBox validates using standard Json Schema assertion policies by default. The TypeSystemPolicy module can override some of these to have TypeBox assert values inline with TypeScript static checks. It also provides overrides for certain checking rules related to non-serializable values (such as void) which can be helpful in Json based protocols such as Json Rpc 2.0.
1626
+
1627
+ The following overrides are available.
1628
+
1629
+ ```typescript
1630
+ import { TypeSystemPolicy } from '@sinclair/typebox/system'
1631
+
1632
+ // Disallow undefined values for optional properties (default is false)
1633
+ //
1634
+ // const A: { x?: number } = { x: undefined } - disallowed when enabled
1635
+
1636
+ TypeSystemPolicy.ExactOptionalPropertyTypes = true
1637
+
1638
+ // Allow arrays to validate as object types (default is false)
1639
+ //
1640
+ // const A: {} = [] - allowed in TS
1641
+
1642
+ TypeSystemPolicy.AllowArrayObject = true
1643
+
1644
+ // Allow numeric values to be NaN or + or - Infinity (default is false)
1645
+ //
1646
+ // const A: number = NaN - allowed in TS
1647
+
1648
+ TypeSystemPolicy.AllowNaN = true
1649
+
1650
+ // Allow void types to check with undefined and null (default is false)
1651
+ //
1652
+ // Used to signal void return on Json-Rpc 2.0 protocol
1653
+
1654
+ TypeSystemPolicy.AllowNullVoid = true
1655
+ ```
1656
+
1657
+ <a name='error-function'></a>
1658
+
1659
+ ## Error Function
1660
+
1661
+ Error messages in TypeBox can be customized by defining an ErrorFunction. This function allows for the localization of error messages as well as enabling custom error messages for custom types. By default, TypeBox will generate messages using the `en-US` locale. To support additional locales, you can replicate the function found in `src/errors/function.ts` and create a locale specific translation. The function can then be set via SetErrorFunction.
1662
+
1663
+ The following example shows an inline error function that intercepts errors for String, Number and Boolean only. The DefaultErrorFunction is used to return a default error message.
1664
+
1665
+
1666
+ ```typescript
1667
+ import { SetErrorFunction, DefaultErrorFunction, ValueErrorType } from '@sinclair/typebox/errors'
1668
+
1669
+ SetErrorFunction((error) => { // i18n override
1670
+ switch(error.errorType) {
1671
+ /* en-US */ case ValueErrorType.String: return 'Expected string'
1672
+ /* fr-FR */ case ValueErrorType.Number: return 'Nombre attendu'
1673
+ /* ko-KR */ case ValueErrorType.Boolean: return '예상 부울'
1674
+ /* en-US */ default: return DefaultErrorFunction(error)
1675
+ }
1676
+ })
1677
+ const T = Type.Object({ // const T: TObject<{
1678
+ x: Type.String(), // TString,
1679
+ y: Type.Number(), // TNumber,
1680
+ z: Type.Boolean() // TBoolean
1681
+ }) // }>
1682
+
1683
+ const E = [...Value.Errors(T, { // const E = [{
1684
+ x: null, // type: 48,
1685
+ y: null, // schema: { ... },
1686
+ z: null // path: '/x',
1687
+ })] // value: null,
1688
+ // message: 'Expected string'
1689
+ // }, {
1690
+ // type: 34,
1691
+ // schema: { ... },
1692
+ // path: '/y',
1693
+ // value: null,
1694
+ // message: 'Nombre attendu'
1695
+ // }, {
1696
+ // type: 14,
1697
+ // schema: { ... },
1698
+ // path: '/z',
1699
+ // value: null,
1700
+ // message: '예상 부울'
1701
+ // }]
1702
+ ```
1703
+
1704
+ <a name='workbench'></a>
1705
+
1706
+ ## TypeBox Workbench
1707
+
1708
+ TypeBox offers a web based code generation tool that can convert TypeScript types into TypeBox types as well as several other ecosystem libraries.
1709
+
1710
+ [TypeBox Workbench Link Here](https://sinclairzx81.github.io/typebox-workbench/)
1711
+
1712
+ <a name='codegen'></a>
1713
+
1714
+ ## TypeBox Codegen
1715
+
1716
+ TypeBox provides a code generation library that can be integrated into toolchains to automate type translation between TypeScript and TypeBox. This library also includes functionality to transform TypeScript types to other ecosystem libraries.
1717
+
1718
+ [TypeBox Codegen Link Here](https://github.com/sinclairzx81/typebox-codegen)
1719
+
1720
+ <a name='ecosystem'></a>
1721
+
1722
+ ## Ecosystem
1723
+
1724
+ The following is a list of community packages that offer general tooling, extended functionality and framework integration support for TypeBox.
1725
+
1726
+ | Package | Description |
1727
+ | ------------- | ------------- |
1728
+ | [drizzle-typebox](https://www.npmjs.com/package/drizzle-typebox) | Generates TypeBox types from Drizzle ORM schemas |
1729
+ | [elysia](https://github.com/elysiajs/elysia) | Fast and friendly Bun web framework |
1730
+ | [fastify-type-provider-typebox](https://github.com/fastify/fastify-type-provider-typebox) | Fastify TypeBox integration with the Fastify Type Provider |
1731
+ | [feathersjs](https://github.com/feathersjs/feathers) | The API and real-time application framework |
1732
+ | [fetch-typebox](https://github.com/erfanium/fetch-typebox) | Drop-in replacement for fetch that brings easy integration with TypeBox |
1733
+ | [@lonli-lokli/fetcher-typebox](https://github.com/Lonli-Lokli/fetcher-ts/tree/master/packages/fetcher-typebox) | A strongly-typed fetch wrapper for TypeScript applications with optional runtime validation using TypeBox |
1734
+ | [h3-typebox](https://github.com/kevinmarrec/h3-typebox) | Schema validation utilities for h3 using TypeBox & Ajv |
1735
+ | [http-wizard](https://github.com/flodlc/http-wizard) | Type safe http client library for Fastify |
1736
+ | [json2typebox](https://github.com/hacxy/json2typebox) | Creating TypeBox code from Json Data |
1737
+ | [nominal-typebox](https://github.com/Coder-Spirit/nominal/tree/main/%40coderspirit/nominal-typebox) | Allows devs to integrate nominal types into TypeBox schemas |
1738
+ | [openapi-box](https://github.com/geut/openapi-box) | Generate TypeBox types from OpenApi IDL + Http client library |
1739
+ | [prismabox](https://github.com/m1212e/prismabox) | Converts a prisma.schema to TypeBox schema matching the database models |
1740
+ | [schema2typebox](https://github.com/xddq/schema2typebox) | Creating TypeBox code from Json Schemas |
1741
+ | [sveltekit-superforms](https://github.com/ciscoheat/sveltekit-superforms) | A comprehensive SvelteKit form library for server and client validation |
1742
+ | [ts2typebox](https://github.com/xddq/ts2typebox) | Creating TypeBox code from Typescript types |
1743
+ | [typebox-cli](https://github.com/gsuess/typebox-cli) | Generate Schema with TypeBox from the CLI |
1744
+ | [typebox-form-parser](https://github.com/jtlapp/typebox-form-parser) | Parses form and query data based on TypeBox schemas |
1745
+ | [typebox-schema-faker](https://github.com/iam-medvedev/typebox-schema-faker) | Generate fake data from TypeBox schemas for testing, prototyping and development |
1746
+
1747
+
1748
+ <a name='benchmark'></a>
1749
+
1750
+ ## Benchmark
1751
+
1752
+ This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.12.0 running on Node 20.10.0.
1753
+
1754
+ For additional comparative benchmarks, please refer to [typescript-runtime-type-benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/).
1755
+
1756
+ <a name='benchmark-compile'></a>
1757
+
1758
+ ### Compile
1759
+
1760
+ This benchmark measures compilation performance for varying types.
1761
+
1762
+ ```typescript
1763
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1764
+ │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1765
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1766
+ │ Literal_String │ 1000 │ ' 211 ms' │ ' 8 ms' │ ' 26.38 x' │
1767
+ │ Literal_Number │ 1000 │ ' 185 ms' │ ' 5 ms' │ ' 37.00 x' │
1768
+ │ Literal_Boolean │ 1000 │ ' 195 ms' │ ' 4 ms' │ ' 48.75 x' │
1769
+ │ Primitive_Number │ 1000 │ ' 149 ms' │ ' 7 ms' │ ' 21.29 x' │
1770
+ │ Primitive_String │ 1000 │ ' 135 ms' │ ' 5 ms' │ ' 27.00 x' │
1771
+ │ Primitive_String_Pattern │ 1000 │ ' 193 ms' │ ' 10 ms' │ ' 19.30 x' │
1772
+ │ Primitive_Boolean │ 1000 │ ' 152 ms' │ ' 4 ms' │ ' 38.00 x' │
1773
+ │ Primitive_Null │ 1000 │ ' 147 ms' │ ' 4 ms' │ ' 36.75 x' │
1774
+ │ Object_Unconstrained │ 1000 │ ' 1065 ms' │ ' 26 ms' │ ' 40.96 x' │
1775
+ │ Object_Constrained │ 1000 │ ' 1183 ms' │ ' 26 ms' │ ' 45.50 x' │
1776
+ │ Object_Vector3 │ 1000 │ ' 407 ms' │ ' 9 ms' │ ' 45.22 x' │
1777
+ │ Object_Box3D │ 1000 │ ' 1777 ms' │ ' 24 ms' │ ' 74.04 x' │
1778
+ │ Tuple_Primitive │ 1000 │ ' 485 ms' │ ' 11 ms' │ ' 44.09 x' │
1779
+ │ Tuple_Object │ 1000 │ ' 1344 ms' │ ' 17 ms' │ ' 79.06 x' │
1780
+ │ Composite_Intersect │ 1000 │ ' 606 ms' │ ' 14 ms' │ ' 43.29 x' │
1781
+ │ Composite_Union │ 1000 │ ' 522 ms' │ ' 17 ms' │ ' 30.71 x' │
1782
+ │ Math_Vector4 │ 1000 │ ' 851 ms' │ ' 9 ms' │ ' 94.56 x' │
1783
+ │ Math_Matrix4 │ 1000 │ ' 406 ms' │ ' 10 ms' │ ' 40.60 x' │
1784
+ │ Array_Primitive_Number │ 1000 │ ' 367 ms' │ ' 6 ms' │ ' 61.17 x' │
1785
+ │ Array_Primitive_String │ 1000 │ ' 339 ms' │ ' 7 ms' │ ' 48.43 x' │
1786
+ │ Array_Primitive_Boolean │ 1000 │ ' 325 ms' │ ' 5 ms' │ ' 65.00 x' │
1787
+ │ Array_Object_Unconstrained │ 1000 │ ' 1863 ms' │ ' 21 ms' │ ' 88.71 x' │
1788
+ │ Array_Object_Constrained │ 1000 │ ' 1535 ms' │ ' 18 ms' │ ' 85.28 x' │
1789
+ │ Array_Tuple_Primitive │ 1000 │ ' 829 ms' │ ' 14 ms' │ ' 59.21 x' │
1790
+ │ Array_Tuple_Object │ 1000 │ ' 1674 ms' │ ' 14 ms' │ ' 119.57 x' │
1791
+ │ Array_Composite_Intersect │ 1000 │ ' 789 ms' │ ' 13 ms' │ ' 60.69 x' │
1792
+ │ Array_Composite_Union │ 1000 │ ' 822 ms' │ ' 15 ms' │ ' 54.80 x' │
1793
+ │ Array_Math_Vector4 │ 1000 │ ' 1129 ms' │ ' 14 ms' │ ' 80.64 x' │
1794
+ │ Array_Math_Matrix4 │ 1000 │ ' 673 ms' │ ' 9 ms' │ ' 74.78 x' │
1795
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1796
+ ```
1797
+
1798
+ <a name='benchmark-validate'></a>
1799
+
1800
+ ### Validate
1801
+
1802
+ This benchmark measures validation performance for varying types.
1803
+
1804
+ ```typescript
1805
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1806
+ │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1807
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1808
+ │ Literal_String │ 1000000 │ ' 17 ms' │ ' 5 ms' │ ' 5 ms' │ ' 1.00 x' │
1809
+ │ Literal_Number │ 1000000 │ ' 14 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1810
+ │ Literal_Boolean │ 1000000 │ ' 14 ms' │ ' 20 ms' │ ' 9 ms' │ ' 2.22 x' │
1811
+ │ Primitive_Number │ 1000000 │ ' 17 ms' │ ' 19 ms' │ ' 9 ms' │ ' 2.11 x' │
1812
+ │ Primitive_String │ 1000000 │ ' 17 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1813
+ │ Primitive_String_Pattern │ 1000000 │ ' 172 ms' │ ' 46 ms' │ ' 41 ms' │ ' 1.12 x' │
1814
+ │ Primitive_Boolean │ 1000000 │ ' 14 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1815
+ │ Primitive_Null │ 1000000 │ ' 16 ms' │ ' 19 ms' │ ' 9 ms' │ ' 2.11 x' │
1816
+ │ Object_Unconstrained │ 1000000 │ ' 437 ms' │ ' 28 ms' │ ' 14 ms' │ ' 2.00 x' │
1817
+ │ Object_Constrained │ 1000000 │ ' 653 ms' │ ' 46 ms' │ ' 37 ms' │ ' 1.24 x' │
1818
+ │ Object_Vector3 │ 1000000 │ ' 201 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1819
+ │ Object_Box3D │ 1000000 │ ' 961 ms' │ ' 37 ms' │ ' 19 ms' │ ' 1.95 x' │
1820
+ │ Object_Recursive │ 1000000 │ ' 3715 ms' │ ' 363 ms' │ ' 174 ms' │ ' 2.09 x' │
1821
+ │ Tuple_Primitive │ 1000000 │ ' 107 ms' │ ' 23 ms' │ ' 11 ms' │ ' 2.09 x' │
1822
+ │ Tuple_Object │ 1000000 │ ' 375 ms' │ ' 28 ms' │ ' 15 ms' │ ' 1.87 x' │
1823
+ │ Composite_Intersect │ 1000000 │ ' 377 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1824
+ │ Composite_Union │ 1000000 │ ' 337 ms' │ ' 30 ms' │ ' 17 ms' │ ' 1.76 x' │
1825
+ │ Math_Vector4 │ 1000000 │ ' 137 ms' │ ' 23 ms' │ ' 11 ms' │ ' 2.09 x' │
1826
+ │ Math_Matrix4 │ 1000000 │ ' 576 ms' │ ' 37 ms' │ ' 28 ms' │ ' 1.32 x' │
1827
+ │ Array_Primitive_Number │ 1000000 │ ' 145 ms' │ ' 23 ms' │ ' 12 ms' │ ' 1.92 x' │
1828
+ │ Array_Primitive_String │ 1000000 │ ' 152 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1829
+ │ Array_Primitive_Boolean │ 1000000 │ ' 131 ms' │ ' 20 ms' │ ' 13 ms' │ ' 1.54 x' │
1830
+ │ Array_Object_Unconstrained │ 1000000 │ ' 2821 ms' │ ' 62 ms' │ ' 45 ms' │ ' 1.38 x' │
1831
+ │ Array_Object_Constrained │ 1000000 │ ' 2958 ms' │ ' 119 ms' │ ' 134 ms' │ ' 0.89 x' │
1832
+ │ Array_Object_Recursive │ 1000000 │ ' 14695 ms' │ ' 1621 ms' │ ' 635 ms' │ ' 2.55 x' │
1833
+ │ Array_Tuple_Primitive │ 1000000 │ ' 478 ms' │ ' 35 ms' │ ' 28 ms' │ ' 1.25 x' │
1834
+ │ Array_Tuple_Object │ 1000000 │ ' 1623 ms' │ ' 63 ms' │ ' 48 ms' │ ' 1.31 x' │
1835
+ │ Array_Composite_Intersect │ 1000000 │ ' 1582 ms' │ ' 43 ms' │ ' 30 ms' │ ' 1.43 x' │
1836
+ │ Array_Composite_Union │ 1000000 │ ' 1331 ms' │ ' 76 ms' │ ' 40 ms' │ ' 1.90 x' │
1837
+ │ Array_Math_Vector4 │ 1000000 │ ' 564 ms' │ ' 38 ms' │ ' 24 ms' │ ' 1.58 x' │
1838
+ │ Array_Math_Matrix4 │ 1000000 │ ' 2382 ms' │ ' 111 ms' │ ' 83 ms' │ ' 1.34 x' │
1839
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1840
+ ```
1841
+
1842
+ <a name='benchmark-compression'></a>
1843
+
1844
+ ### Compression
1845
+
1846
+ The following table lists esbuild compiled and minified sizes for each TypeBox module.
1847
+
1848
+ ```typescript
1849
+ ┌──────────────────────┬────────────┬────────────┬─────────────┐
1850
+ │ (index) │ Compiled │ Minified │ Compression │
1851
+ ├──────────────────────┼────────────┼────────────┼─────────────┤
1852
+ │ typebox/compiler │ '122.4 kb' │ ' 53.4 kb' │ '2.29 x' │
1853
+ │ typebox/errors │ ' 67.6 kb' │ ' 29.6 kb' │ '2.28 x' │
1854
+ │ typebox/syntax │ '132.9 kb' │ ' 54.2 kb' │ '2.45 x' │
1855
+ │ typebox/system │ ' 7.4 kb' │ ' 3.2 kb' │ '2.33 x' │
1856
+ │ typebox/value │ '150.1 kb' │ ' 62.2 kb' │ '2.41 x' │
1857
+ │ typebox │ '106.8 kb' │ ' 43.2 kb' │ '2.47 x' │
1858
+ └──────────────────────┴────────────┴────────────┴─────────────┘
1859
+ ```
1860
+
1861
+ <a name='contribute'></a>
1862
+
1863
+ ## Contribute
1864
+
1865
+ TypeBox is open to community contribution. Please ensure you submit an open issue before submitting your pull request. The TypeBox project prefers open community discussion before accepting new features.