@sinclair/typebox 0.32.0-dev-14 → 0.32.0-dev-16

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 (236) hide show
  1. package/build/import/index.d.mts +12 -12
  2. package/build/import/index.mjs +5 -5
  3. package/build/import/type/array/array.d.mts +1 -1
  4. package/build/import/type/constructor/constructor.d.mts +4 -4
  5. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +13 -0
  6. package/build/import/type/exclude/exclude-from-mapped-result.mjs +14 -0
  7. package/build/import/type/exclude/exclude.d.mts +7 -4
  8. package/build/import/type/exclude/exclude.mjs +10 -4
  9. package/build/import/type/exclude/index.d.mts +1 -0
  10. package/build/import/type/exclude/index.mjs +1 -0
  11. package/build/import/type/extends/extends-from-mapped-key.d.mts +17 -0
  12. package/build/import/type/extends/extends-from-mapped-key.mjs +21 -0
  13. package/build/import/type/extends/extends-from-mapped-result.d.mts +13 -0
  14. package/build/import/type/extends/extends-from-mapped-result.mjs +14 -0
  15. package/build/import/type/extends/extends.d.mts +4 -4
  16. package/build/import/type/extends/extends.mjs +5 -5
  17. package/build/import/type/extends/index.d.mts +2 -2
  18. package/build/import/type/extends/index.mjs +2 -2
  19. package/build/import/type/extract/extract-from-mapped-result.d.mts +13 -0
  20. package/build/import/type/extract/extract-from-mapped-result.mjs +14 -0
  21. package/build/import/type/extract/extract.d.mts +6 -3
  22. package/build/import/type/extract/extract.mjs +9 -3
  23. package/build/import/type/extract/index.d.mts +1 -0
  24. package/build/import/type/extract/index.mjs +1 -0
  25. package/build/import/type/function/function.d.mts +4 -4
  26. package/build/import/type/indexed/index.d.mts +1 -1
  27. package/build/import/type/indexed/index.mjs +1 -1
  28. package/build/import/type/indexed/{indexed-mapped-result.d.mts → indexed-from-mapped-key.d.mts} +6 -6
  29. package/build/import/type/indexed/indexed-from-mapped-key.mjs +18 -0
  30. package/build/import/type/indexed/indexed-result.d.mts +8 -8
  31. package/build/import/type/indexed/indexed-result.mjs +9 -8
  32. package/build/import/type/indexed/indexed.d.mts +2 -2
  33. package/build/import/type/indexed/indexed.mjs +5 -5
  34. package/build/import/type/intersect/index.d.mts +2 -0
  35. package/build/import/type/intersect/index.mjs +2 -0
  36. package/build/import/type/intersect/intersect-create.d.mts +3 -0
  37. package/build/import/type/intersect/intersect-create.mjs +12 -0
  38. package/build/import/type/intersect/intersect-evaluated.d.mts +16 -0
  39. package/build/import/type/intersect/intersect-evaluated.mjs +35 -0
  40. package/build/import/type/intersect/intersect-type.d.mts +15 -0
  41. package/build/import/type/intersect/intersect-type.mjs +1 -0
  42. package/build/import/type/intersect/intersect.d.mts +4 -20
  43. package/build/import/type/intersect/intersect.mjs +5 -17
  44. package/build/import/type/intrinsic/capitalize.mjs +1 -2
  45. package/build/import/type/intrinsic/index.d.mts +1 -1
  46. package/build/import/type/intrinsic/index.mjs +1 -1
  47. package/build/import/type/intrinsic/{intrinsic-mapped-result.d.mts → intrinsic-from-mapped-key.d.mts} +6 -5
  48. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +21 -0
  49. package/build/import/type/intrinsic/intrinsic.d.mts +6 -6
  50. package/build/import/type/intrinsic/intrinsic.mjs +8 -8
  51. package/build/import/type/intrinsic/lowercase.mjs +1 -2
  52. package/build/import/type/intrinsic/uncapitalize.mjs +1 -2
  53. package/build/import/type/intrinsic/uppercase.mjs +1 -2
  54. package/build/import/type/keyof/index.d.mts +1 -0
  55. package/build/import/type/keyof/index.mjs +1 -0
  56. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +13 -0
  57. package/build/import/type/keyof/keyof-from-mapped-result.mjs +14 -0
  58. package/build/import/type/keyof/keyof.d.mts +5 -2
  59. package/build/import/type/keyof/keyof.mjs +10 -3
  60. package/build/import/type/mapped/mapped.mjs +1 -2
  61. package/build/import/type/object/object.d.mts +5 -5
  62. package/build/import/type/omit/index.d.mts +1 -1
  63. package/build/import/type/omit/index.mjs +1 -1
  64. package/build/import/type/omit/omit-from-mapped-key.d.mts +15 -0
  65. package/build/import/type/omit/omit-from-mapped-key.mjs +20 -0
  66. package/build/import/type/omit/omit.d.mts +2 -2
  67. package/build/import/type/omit/omit.mjs +2 -2
  68. package/build/import/type/partial/index.d.mts +1 -0
  69. package/build/import/type/partial/index.mjs +1 -0
  70. package/build/import/type/partial/partial-from-mapped-result.d.mts +13 -0
  71. package/build/import/type/partial/partial-from-mapped-result.mjs +14 -0
  72. package/build/import/type/partial/partial.d.mts +5 -2
  73. package/build/import/type/partial/partial.mjs +11 -5
  74. package/build/import/type/pick/index.d.mts +1 -1
  75. package/build/import/type/pick/index.mjs +1 -1
  76. package/build/import/type/pick/pick-from-mapped-key.d.mts +15 -0
  77. package/build/import/type/pick/pick-from-mapped-key.mjs +20 -0
  78. package/build/import/type/pick/pick.d.mts +2 -2
  79. package/build/import/type/pick/pick.mjs +2 -2
  80. package/build/import/type/record/record.d.mts +0 -1
  81. package/build/import/type/record/record.mjs +1 -1
  82. package/build/import/type/recursive/recursive.d.mts +3 -2
  83. package/build/import/type/recursive/recursive.mjs +1 -5
  84. package/build/import/type/required/index.d.mts +1 -0
  85. package/build/import/type/required/index.mjs +1 -0
  86. package/build/import/type/required/required-from-mapped-result.d.mts +13 -0
  87. package/build/import/type/required/required-from-mapped-result.mjs +14 -0
  88. package/build/import/type/required/required.d.mts +5 -2
  89. package/build/import/type/required/required.mjs +11 -5
  90. package/build/import/type/template-literal/syntax.d.mts +4 -4
  91. package/build/import/type/template-literal/template-literal.d.mts +4 -4
  92. package/build/import/type/transform/transform.d.mts +3 -2
  93. package/build/import/type/transform/transform.mjs +1 -1
  94. package/build/import/type/tuple/tuple.d.mts +3 -3
  95. package/build/import/type/type/json.d.mts +25 -20
  96. package/build/import/type/type/json.mjs +3 -3
  97. package/build/import/type/union/index.d.mts +2 -0
  98. package/build/import/type/union/index.mjs +2 -0
  99. package/build/import/type/union/union-create.d.mts +3 -0
  100. package/build/import/type/union/union-create.mjs +5 -0
  101. package/build/import/type/union/union-evaluated.d.mts +16 -0
  102. package/build/import/type/union/union-evaluated.mjs +31 -0
  103. package/build/import/type/union/union-type.d.mts +12 -0
  104. package/build/import/type/union/union-type.mjs +1 -0
  105. package/build/import/type/union/union.d.mts +3 -13
  106. package/build/import/type/union/union.mjs +3 -10
  107. package/build/import/value/delta/delta.d.mts +1 -1
  108. package/build/require/index.d.ts +12 -12
  109. package/build/require/index.js +8 -3
  110. package/build/require/type/array/array.d.ts +1 -1
  111. package/build/require/type/constructor/constructor.d.ts +4 -4
  112. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +13 -0
  113. package/build/require/type/exclude/exclude-from-mapped-result.js +18 -0
  114. package/build/require/type/exclude/exclude.d.ts +7 -4
  115. package/build/require/type/exclude/exclude.js +9 -4
  116. package/build/require/type/exclude/index.d.ts +1 -0
  117. package/build/require/type/exclude/index.js +1 -0
  118. package/build/require/type/extends/extends-from-mapped-key.d.ts +17 -0
  119. package/build/require/type/extends/extends-from-mapped-key.js +25 -0
  120. package/build/require/type/extends/extends-from-mapped-result.d.ts +13 -0
  121. package/build/require/type/extends/extends-from-mapped-result.js +18 -0
  122. package/build/require/type/extends/extends.d.ts +4 -4
  123. package/build/require/type/extends/extends.js +7 -7
  124. package/build/require/type/extends/index.d.ts +2 -2
  125. package/build/require/type/extends/index.js +2 -2
  126. package/build/require/type/extract/extract-from-mapped-result.d.ts +13 -0
  127. package/build/require/type/extract/extract-from-mapped-result.js +18 -0
  128. package/build/require/type/extract/extract.d.ts +6 -3
  129. package/build/require/type/extract/extract.js +8 -2
  130. package/build/require/type/extract/index.d.ts +1 -0
  131. package/build/require/type/extract/index.js +1 -0
  132. package/build/require/type/function/function.d.ts +4 -4
  133. package/build/require/type/indexed/index.d.ts +1 -1
  134. package/build/require/type/indexed/index.js +1 -1
  135. package/build/require/type/indexed/{indexed-mapped-result.d.ts → indexed-from-mapped-key.d.ts} +6 -6
  136. package/build/require/type/indexed/indexed-from-mapped-key.js +22 -0
  137. package/build/require/type/indexed/indexed-result.d.ts +8 -8
  138. package/build/require/type/indexed/indexed-result.js +14 -13
  139. package/build/require/type/indexed/indexed.d.ts +2 -2
  140. package/build/require/type/indexed/indexed.js +6 -6
  141. package/build/require/type/intersect/index.d.ts +2 -0
  142. package/build/require/type/intersect/index.js +2 -0
  143. package/build/require/type/intersect/intersect-create.d.ts +3 -0
  144. package/build/require/type/intersect/intersect-create.js +16 -0
  145. package/build/require/type/intersect/intersect-evaluated.d.ts +16 -0
  146. package/build/require/type/intersect/intersect-evaluated.js +39 -0
  147. package/build/require/type/intersect/intersect-type.d.ts +15 -0
  148. package/build/require/type/intersect/intersect-type.js +3 -0
  149. package/build/require/type/intersect/intersect.d.ts +4 -20
  150. package/build/require/type/intersect/intersect.js +5 -18
  151. package/build/require/type/intrinsic/capitalize.js +1 -2
  152. package/build/require/type/intrinsic/index.d.ts +1 -1
  153. package/build/require/type/intrinsic/index.js +1 -1
  154. package/build/require/type/intrinsic/{intrinsic-mapped-result.d.ts → intrinsic-from-mapped-key.d.ts} +6 -5
  155. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +25 -0
  156. package/build/require/type/intrinsic/intrinsic.d.ts +6 -6
  157. package/build/require/type/intrinsic/intrinsic.js +8 -8
  158. package/build/require/type/intrinsic/lowercase.js +1 -2
  159. package/build/require/type/intrinsic/uncapitalize.js +1 -2
  160. package/build/require/type/intrinsic/uppercase.js +1 -2
  161. package/build/require/type/keyof/index.d.ts +1 -0
  162. package/build/require/type/keyof/index.js +1 -0
  163. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +13 -0
  164. package/build/require/type/keyof/keyof-from-mapped-result.js +18 -0
  165. package/build/require/type/keyof/keyof.d.ts +5 -2
  166. package/build/require/type/keyof/keyof.js +9 -2
  167. package/build/require/type/mapped/mapped.js +18 -19
  168. package/build/require/type/object/object.d.ts +5 -5
  169. package/build/require/type/omit/index.d.ts +1 -1
  170. package/build/require/type/omit/index.js +1 -1
  171. package/build/require/type/omit/omit-from-mapped-key.d.ts +15 -0
  172. package/build/require/type/omit/omit-from-mapped-key.js +24 -0
  173. package/build/require/type/omit/omit.d.ts +2 -2
  174. package/build/require/type/omit/omit.js +2 -2
  175. package/build/require/type/partial/index.d.ts +1 -0
  176. package/build/require/type/partial/index.js +1 -0
  177. package/build/require/type/partial/partial-from-mapped-result.d.ts +13 -0
  178. package/build/require/type/partial/partial-from-mapped-result.js +18 -0
  179. package/build/require/type/partial/partial.d.ts +5 -2
  180. package/build/require/type/partial/partial.js +10 -5
  181. package/build/require/type/pick/index.d.ts +1 -1
  182. package/build/require/type/pick/index.js +1 -1
  183. package/build/require/type/pick/pick-from-mapped-key.d.ts +15 -0
  184. package/build/require/type/pick/pick-from-mapped-key.js +24 -0
  185. package/build/require/type/pick/pick.d.ts +2 -2
  186. package/build/require/type/pick/pick.js +2 -2
  187. package/build/require/type/record/record.d.ts +0 -1
  188. package/build/require/type/record/record.js +1 -2
  189. package/build/require/type/recursive/recursive.d.ts +3 -2
  190. package/build/require/type/recursive/recursive.js +1 -5
  191. package/build/require/type/required/index.d.ts +1 -0
  192. package/build/require/type/required/index.js +1 -0
  193. package/build/require/type/required/required-from-mapped-result.d.ts +13 -0
  194. package/build/require/type/required/required-from-mapped-result.js +18 -0
  195. package/build/require/type/required/required.d.ts +5 -2
  196. package/build/require/type/required/required.js +10 -5
  197. package/build/require/type/template-literal/syntax.d.ts +4 -4
  198. package/build/require/type/template-literal/template-literal.d.ts +4 -4
  199. package/build/require/type/transform/transform.d.ts +3 -2
  200. package/build/require/type/transform/transform.js +4 -4
  201. package/build/require/type/tuple/tuple.d.ts +3 -3
  202. package/build/require/type/type/json.d.ts +25 -20
  203. package/build/require/type/type/json.js +3 -3
  204. package/build/require/type/union/index.d.ts +2 -0
  205. package/build/require/type/union/index.js +2 -0
  206. package/build/require/type/union/union-create.d.ts +3 -0
  207. package/build/require/type/union/union-create.js +9 -0
  208. package/build/require/type/union/union-evaluated.d.ts +16 -0
  209. package/build/require/type/union/union-evaluated.js +35 -0
  210. package/build/require/type/union/union-type.d.ts +12 -0
  211. package/build/require/type/union/union-type.js +3 -0
  212. package/build/require/type/union/union.d.ts +3 -13
  213. package/build/require/type/union/union.js +3 -11
  214. package/build/require/value/delta/delta.d.ts +1 -1
  215. package/package.json +1 -1
  216. package/readme.md +97 -101
  217. package/build/import/type/extends/extends-mapped-result-from-result.d.mts +0 -13
  218. package/build/import/type/extends/extends-mapped-result-from-result.mjs +0 -14
  219. package/build/import/type/extends/extends-mapped-result.d.mts +0 -17
  220. package/build/import/type/extends/extends-mapped-result.mjs +0 -21
  221. package/build/import/type/indexed/indexed-mapped-result.mjs +0 -18
  222. package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +0 -21
  223. package/build/import/type/omit/omit-mapped-result.d.mts +0 -15
  224. package/build/import/type/omit/omit-mapped-result.mjs +0 -20
  225. package/build/import/type/pick/pick-mapped-result.d.mts +0 -15
  226. package/build/import/type/pick/pick-mapped-result.mjs +0 -20
  227. package/build/require/type/extends/extends-mapped-result-from-result.d.ts +0 -13
  228. package/build/require/type/extends/extends-mapped-result-from-result.js +0 -18
  229. package/build/require/type/extends/extends-mapped-result.d.ts +0 -17
  230. package/build/require/type/extends/extends-mapped-result.js +0 -25
  231. package/build/require/type/indexed/indexed-mapped-result.js +0 -22
  232. package/build/require/type/intrinsic/intrinsic-mapped-result.js +0 -25
  233. package/build/require/type/omit/omit-mapped-result.d.ts +0 -15
  234. package/build/require/type/omit/omit-mapped-result.js +0 -24
  235. package/build/require/type/pick/pick-mapped-result.d.ts +0 -15
  236. package/build/require/type/pick/pick-mapped-result.js +0 -24
package/readme.md CHANGED
@@ -52,9 +52,9 @@ type T = Static<typeof T> // type T = {
52
52
 
53
53
  ## Overview
54
54
 
55
- TypeBox is a runtime type builder that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type assertion rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.
55
+ TypeBox is a runtime type builder that creates in-memory Json Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
56
56
 
57
- This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.
57
+ This library enables Json Schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.
58
58
 
59
59
  License MIT
60
60
 
@@ -65,9 +65,9 @@ License MIT
65
65
  - [Types](#types)
66
66
  - [Json](#types-json)
67
67
  - [JavaScript](#types-javascript)
68
+ - [Modules](#types-modules)
68
69
  - [Options](#types-options)
69
70
  - [Properties](#types-properties)
70
- - [Imports](#types-imports)
71
71
  - [Generics](#types-generics)
72
72
  - [References](#types-references)
73
73
  - [Recursive](#types-recursive)
@@ -644,6 +644,28 @@ TypeBox provides an extended type set that can be used to create schematics for
644
644
  └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
645
645
  ```
646
646
 
647
+ <a name='types-modules'></a>
648
+
649
+ ### Type Modules
650
+
651
+ TypeBox uses a modular type system and supports selective type imports. Using selective imports can be useful in resource constrained environments as the technique allows modern bundlers to tree shake unused types. This can reduce overall bundle sizes.
652
+
653
+ ```typescript
654
+ import { Object, Number, String, Boolean, type Static } from '@sinclair/typebox'
655
+
656
+ const T = Object({ // const T: TObject<{
657
+ x: Number(), // x: TNumber,
658
+ y: String(), // y: TString,
659
+ z: Boolean() // z: TBoolean
660
+ }) // }>
661
+
662
+ type T = Static<typeof T> // type T = {
663
+ // x: number,
664
+ // y: string,
665
+ // z: boolean
666
+ // }
667
+ ```
668
+
647
669
  <a name='types-options'></a>
648
670
 
649
671
  ### Options
@@ -717,31 +739,6 @@ Object properties can be modified with Readonly and Optional. The following tabl
717
739
  └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
718
740
  ```
719
741
 
720
- <a name='types-imports'></a>
721
-
722
- ### Import Types
723
-
724
- TypeBox supports a modular type system. For most users, importing the full type system is generally recommended as it offers the best overall user experience as well as enabling easier discovery of available types.
725
-
726
- ```typescript
727
- import { Type } from '@sinclair/typebox' // 34.9 kb minified
728
-
729
- const T = Type.Object({
730
- x: Type.Number(),
731
- y: Type.Number()
732
- })
733
- ```
734
- For developers building for resource constrained environments, selective imports can allow bundle optimizers to tree shake unused types. This can dramatically reduce bundle output sizes.
735
- ```typescript
736
- import { Object, Number } from '@sinclair/typebox' // 6.4 kb minified
737
-
738
- const T = Object({
739
- x: Number(),
740
- y: Number()
741
- })
742
- ```
743
- For additional information on bundle optimizations, refer to the documentation provided by your bundler of choice.
744
-
745
742
  <a name='types-generics'></a>
746
743
 
747
744
  ### Generic Types
@@ -811,7 +808,7 @@ type VectorRef = Static<typeof VectorRef> // type VectorRef = {
811
808
  // y: number
812
809
  // }
813
810
  ```
814
- Use Type.Deref to dereference a type. This type will recursively reconstruct interior referenced types.
811
+ Use Type.Deref to dereference a type. This will replace any `$ref` with the target type.
815
812
  ```typescript
816
813
  const Vertex = Type.Object({ // const Vertex = {
817
814
  position: VectorRef, // type: 'object',
@@ -890,7 +887,7 @@ function test(node: Node) {
890
887
 
891
888
  ### Conditional Types
892
889
 
893
- TypeBox supports runtime Conditional Types with Type.Extends. This type runs a structural assignability check against the first and second arguments and will return either the third (`true`) or fourth (`false`) argument based on the result. Additionally, the conditional backed types Exclude and Extract are also supported. The following shows both TypeScript and TypeBox examples of this feature.
890
+ TypeBox supports runtime Conditional types with Type.Extends. This type runs a structural assignability check against the first and second 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.
894
891
 
895
892
  ```typescript
896
893
  // Extends
@@ -935,7 +932,7 @@ const T = Type.Exclude( // const T: TUnion<[
935
932
 
936
933
  ### Mapped Types
937
934
 
938
- TypeBox supports Mapped Types with Type.Mapped. This type accepts a union set of property keys as the first argument, and a type mapping function which accepts each key (`K`) as the second. This type can be used with Conditional and Indexed Access types to allow for generalized property remapping irrespective of property type. The following example remaps each property of `T` to be `T[K] | null`.
935
+ TypeBox supports Mapped types with Type.Mapped. This type accepts a union of property keys as the first argument, and a type mapping function which accepts each key (`K`) as the second. This type can be used with Conditional and Indexed Access types to allow for generalized property remapping irrespective of property type. The following example remaps each property of `T` to be `T[K] | null`.
939
936
 
940
937
  ```typescript
941
938
  const T = Type.Object({ // const T: TObject<{
@@ -961,7 +958,7 @@ const M = Type.Mapped(Type.KeyOf(T), K => { // type M = {
961
958
 
962
959
  ### Template Literal Types
963
960
 
964
- TypeBox supports Template Literal types with Type.TemplateLiteral. This type can be created using a syntax similar to the TypeScript Template Literal syntax. TypeBox encodes Template Literals as regular expression string patterns which enables the template to be checked by Json Schema validators. This type also supports regular expression parsing, enabling template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.
961
+ TypeBox supports template literals with Type.TemplateLiteral. 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 expression patterns which enables the template to be checked by Json Schema validators. This type also supports regular expression parsing, enabling template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.
965
962
 
966
963
  ```typescript
967
964
  // TypeScript
@@ -996,7 +993,7 @@ const R = Type.Record(K, Type.String()) // const R: TObject<{
996
993
 
997
994
  ### Indexed Access Types
998
995
 
999
- TypeBox supports Indexed Access Types with Type.Index. This type enables uniform access to interior property and array element types without having to extract them from the underlying schema representation. This type is supported for Object, Array, Tuple, Union and Intersect types.
996
+ TypeBox supports Indexed Access types with Type.Index. This type enables uniform access to interior property and array element types without having to extract them from the underlying schema representation. This type is supported for Object, Array, Tuple, Union and Intersect types.
1000
997
 
1001
998
  ```typescript
1002
999
  const T = Type.Object({ // const T: TObject<{
@@ -1140,7 +1137,7 @@ type S = Static<typeof T> // type S = 'A' | 'B' | 'C'
1140
1137
 
1141
1138
  ### TypeGuard
1142
1139
 
1143
- TypeBox can type check its own types with the TypeGuard module. This module is written for reflection and provides structural tests for every TypeBox type. Functions of this module return `is` guards which can be used with TypeScript control flow assertions to obtain schema inference. The following guards that the value A is TString.
1140
+ TypeBox can type check its own types with the TypeGuard module. This module is written for reflection and provides structural tests for every built-in TypeBox type. Functions of this module return `is` guards which can be used with TypeScript control flow assertions to obtain schema inference. The following guards that the value A is TString.
1144
1141
 
1145
1142
  ```typescript
1146
1143
  import { Type, TypeGuard } from '@sinclair/typebox'
@@ -1593,7 +1590,7 @@ const C = TypeCompiler.Code(Type.String()) // const C = `return functi
1593
1590
 
1594
1591
  ## TypeSystem
1595
1592
 
1596
- The TypeBox TypeSystem module provides functionality to define types above and beyond the built-in Json and JavaScript type sets. They also manage TypeBox's localization options (i18n) for error message generation and can control various assertion policies used when type checking. Configurations made to the TypeSystem module are observed by the TypeCompiler, Value and Error modules.
1593
+ 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.
1597
1594
 
1598
1595
  <a name='typesystem-policies'></a>
1599
1596
 
@@ -1635,7 +1632,7 @@ TypeSystemPolicy.AllowNullVoid = true
1635
1632
 
1636
1633
  ## Error Function
1637
1634
 
1638
- 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 translations. The function can then be set via SetErrorFunction.
1635
+ 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.
1639
1636
 
1640
1637
  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.
1641
1638
 
@@ -1719,7 +1716,7 @@ The following is a list of community packages that offer general tooling, extend
1719
1716
 
1720
1717
  ## Benchmark
1721
1718
 
1722
- 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.0.0.
1719
+ 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.
1723
1720
 
1724
1721
  For additional comparative benchmarks, please refer to [typescript-runtime-type-benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/).
1725
1722
 
@@ -1733,35 +1730,35 @@ This benchmark measures compilation performance for varying types. You can revie
1733
1730
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1734
1731
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1735
1732
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1736
- │ Literal_String │ 1000 │ ' 216 ms' │ ' 9 ms' │ ' 24.00 x' │
1737
- │ Literal_Number │ 1000 │ ' 169 ms' │ ' 7 ms' │ ' 24.14 x' │
1738
- │ Literal_Boolean │ 1000 │ ' 150 ms' │ ' 5 ms' │ ' 30.00 x' │
1739
- │ Primitive_Number │ 1000 │ ' 161 ms' │ ' 7 ms' │ ' 23.00 x' │
1740
- │ Primitive_String │ 1000 │ ' 148 ms' │ ' 6 ms' │ ' 24.67 x' │
1741
- │ Primitive_String_Pattern │ 1000 │ ' 185 ms' │ ' 9 ms' │ ' 20.56 x' │
1742
- │ Primitive_Boolean │ 1000 │ ' 132 ms' │ ' 4 ms' │ ' 33.00 x' │
1743
- │ Primitive_Null │ 1000 │ ' 141 ms' │ ' 3 ms' │ ' 47.00 x' │
1744
- │ Object_Unconstrained │ 1000 │ ' 1109 ms' │ ' 30 ms' │ ' 36.97 x' │
1745
- │ Object_Constrained │ 1000 │ ' 1200 ms' │ ' 24 ms' │ ' 50.00 x' │
1746
- │ Object_Vector3 │ 1000 │ ' 379 ms' │ ' 9 ms' │ ' 42.11 x' │
1747
- │ Object_Box3D │ 1000 │ ' 1709 ms' │ ' 30 ms' │ ' 56.97 x' │
1748
- │ Tuple_Primitive │ 1000 │ ' 456 ms' │ ' 14 ms' │ ' 32.57 x' │
1749
- │ Tuple_Object │ 1000 │ ' 1229 ms' │ ' 17 ms' │ ' 72.29 x' │
1750
- │ Composite_Intersect │ 1000 │ ' 570 ms' │ ' 17 ms' │ ' 33.53 x' │
1751
- │ Composite_Union │ 1000 │ ' 513 ms' │ ' 19 ms' │ ' 27.00 x' │
1752
- │ Math_Vector4 │ 1000 │ ' 782 ms' │ ' 13 ms' │ ' 60.15 x' │
1753
- │ Math_Matrix4 │ 1000 │ ' 393 ms' │ ' 12 ms' │ ' 32.75 x' │
1754
- │ Array_Primitive_Number │ 1000 │ ' 361 ms' │ ' 12 ms' │ ' 30.08 x' │
1755
- │ Array_Primitive_String │ 1000 │ ' 296 ms' │ ' 5 ms' │ ' 59.20 x' │
1756
- │ Array_Primitive_Boolean │ 1000 │ ' 315 ms' │ ' 4 ms' │ ' 78.75 x' │
1757
- │ Array_Object_Unconstrained │ 1000 │ ' 1721 ms' │ ' 22 ms' │ ' 78.23 x' │
1758
- │ Array_Object_Constrained │ 1000 │ ' 1450 ms' │ ' 21 ms' │ ' 69.05 x' │
1759
- │ Array_Tuple_Primitive │ 1000 │ ' 813 ms' │ ' 13 ms' │ ' 62.54 x' │
1760
- │ Array_Tuple_Object │ 1000 │ ' 1537 ms' │ ' 17 ms' │ ' 90.41 x' │
1761
- │ Array_Composite_Intersect │ 1000 │ ' 753 ms' │ ' 17 ms' │ ' 44.29 x' │
1762
- │ Array_Composite_Union │ 1000 │ ' 808 ms' │ ' 16 ms' │ ' 50.50 x' │
1763
- │ Array_Math_Vector4 │ 1000 │ ' 1118 ms' │ ' 16 ms' │ ' 69.88 x' │
1764
- │ Array_Math_Matrix4 │ 1000 │ ' 690 ms' │ ' 9 ms' │ ' 76.67 x' │
1733
+ │ Literal_String │ 1000 │ ' 236 ms' │ ' 9 ms' │ ' 26.22 x' │
1734
+ │ Literal_Number │ 1000 │ ' 205 ms' │ ' 13 ms' │ ' 15.77 x' │
1735
+ │ Literal_Boolean │ 1000 │ ' 168 ms' │ ' 4 ms' │ ' 42.00 x' │
1736
+ │ Primitive_Number │ 1000 │ ' 170 ms' │ ' 8 ms' │ ' 21.25 x' │
1737
+ │ Primitive_String │ 1000 │ ' 162 ms' │ ' 7 ms' │ ' 23.14 x' │
1738
+ │ Primitive_String_Pattern │ 1000 │ ' 211 ms' │ ' 10 ms' │ ' 21.10 x' │
1739
+ │ Primitive_Boolean │ 1000 │ ' 139 ms' │ ' 4 ms' │ ' 34.75 x' │
1740
+ │ Primitive_Null │ 1000 │ ' 146 ms' │ ' 5 ms' │ ' 29.20 x' │
1741
+ │ Object_Unconstrained │ 1000 │ ' 1160 ms' │ ' 33 ms' │ ' 35.15 x' │
1742
+ │ Object_Constrained │ 1000 │ ' 1257 ms' │ ' 26 ms' │ ' 48.35 x' │
1743
+ │ Object_Vector3 │ 1000 │ ' 393 ms' │ ' 8 ms' │ ' 49.13 x' │
1744
+ │ Object_Box3D │ 1000 │ ' 1795 ms' │ ' 30 ms' │ ' 59.83 x' │
1745
+ │ Tuple_Primitive │ 1000 │ ' 542 ms' │ ' 16 ms' │ ' 33.88 x' │
1746
+ │ Tuple_Object │ 1000 │ ' 1330 ms' │ ' 17 ms' │ ' 78.24 x' │
1747
+ │ Composite_Intersect │ 1000 │ ' 624 ms' │ ' 17 ms' │ ' 36.71 x' │
1748
+ │ Composite_Union │ 1000 │ ' 565 ms' │ ' 19 ms' │ ' 29.74 x' │
1749
+ │ Math_Vector4 │ 1000 │ ' 853 ms' │ ' 10 ms' │ ' 85.30 x' │
1750
+ │ Math_Matrix4 │ 1000 │ ' 406 ms' │ ' 12 ms' │ ' 33.83 x' │
1751
+ │ Array_Primitive_Number │ 1000 │ ' 401 ms' │ ' 11 ms' │ ' 36.45 x' │
1752
+ │ Array_Primitive_String │ 1000 │ ' 385 ms' │ ' 6 ms' │ ' 64.17 x' │
1753
+ │ Array_Primitive_Boolean │ 1000 │ ' 347 ms' │ ' 8 ms' │ ' 43.38 x' │
1754
+ │ Array_Object_Unconstrained │ 1000 │ ' 1904 ms' │ ' 25 ms' │ ' 76.16 x' │
1755
+ │ Array_Object_Constrained │ 1000 │ ' 1582 ms' │ ' 20 ms' │ ' 79.10 x' │
1756
+ │ Array_Tuple_Primitive │ 1000 │ ' 864 ms' │ ' 11 ms' │ ' 78.55 x' │
1757
+ │ Array_Tuple_Object │ 1000 │ ' 1658 ms' │ ' 16 ms' │ ' 103.63 x' │
1758
+ │ Array_Composite_Intersect │ 1000 │ ' 786 ms' │ ' 17 ms' │ ' 46.24 x' │
1759
+ │ Array_Composite_Union │ 1000 │ ' 844 ms' │ ' 16 ms' │ ' 52.75 x' │
1760
+ │ Array_Math_Vector4 │ 1000 │ ' 1192 ms' │ ' 10 ms' │ ' 119.20 x' │
1761
+ │ Array_Math_Matrix4 │ 1000 │ ' 688 ms' │ ' 10 ms' │ ' 68.80 x' │
1765
1762
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1766
1763
  ```
1767
1764
 
@@ -1775,37 +1772,37 @@ This benchmark measures validation performance for varying types. You can review
1775
1772
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1776
1773
  │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1777
1774
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1778
- │ Literal_String │ 1000000 │ ' 24 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1779
- │ Literal_Number │ 1000000 │ ' 15 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1775
+ │ Literal_String │ 1000000 │ ' 19 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1776
+ │ Literal_Number │ 1000000 │ ' 14 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1780
1777
  │ Literal_Boolean │ 1000000 │ ' 14 ms' │ ' 19 ms' │ ' 9 ms' │ ' 2.11 x' │
1781
- │ Primitive_Number │ 1000000 │ ' 25 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1782
- │ Primitive_String │ 1000000 │ ' 21 ms' │ ' 24 ms' │ ' 9 ms' │ ' 2.67 x' │
1783
- │ Primitive_String_Pattern │ 1000000 │ ' 156 ms' │ ' 43 ms' │ ' 38 ms' │ ' 1.13 x' │
1784
- │ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1785
- │ Primitive_Null │ 1000000 │ ' 20 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1786
- │ Object_Unconstrained │ 1000000 │ ' 1055 ms' │ ' 32 ms' │ ' 24 ms' │ ' 1.33 x' │
1787
- │ Object_Constrained │ 1000000 │ ' 1232 ms' │ ' 49 ms' │ ' 43 ms' │ ' 1.14 x' │
1788
- │ Object_Vector3 │ 1000000 │ ' 432 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1789
- │ Object_Box3D │ 1000000 │ ' 1993 ms' │ ' 54 ms' │ ' 46 ms' │ ' 1.17 x' │
1790
- │ Object_Recursive │ 1000000 │ ' 5115 ms' │ ' 342 ms' │ ' 159 ms' │ ' 2.15 x' │
1791
- │ Tuple_Primitive │ 1000000 │ ' 156 ms' │ ' 21 ms' │ ' 13 ms' │ ' 1.62 x' │
1792
- │ Tuple_Object │ 1000000 │ ' 740 ms' │ ' 29 ms' │ ' 18 ms' │ ' 1.61 x' │
1793
- │ Composite_Intersect │ 1000000 │ ' 797 ms' │ ' 26 ms' │ ' 14 ms' │ ' 1.86 x' │
1794
- │ Composite_Union │ 1000000 │ ' 530 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1795
- │ Math_Vector4 │ 1000000 │ ' 240 ms' │ ' 22 ms' │ ' 11 ms' │ ' 2.00 x' │
1796
- │ Math_Matrix4 │ 1000000 │ ' 1036 ms' │ ' 39 ms' │ ' 27 ms' │ ' 1.44 x' │
1797
- │ Array_Primitive_Number │ 1000000 │ ' 248 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1798
- │ Array_Primitive_String │ 1000000 │ ' 227 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1799
- │ Array_Primitive_Boolean │ 1000000 │ ' 138 ms' │ ' 21 ms' │ ' 13 ms' │ ' 1.62 x' │
1800
- │ Array_Object_Unconstrained │ 1000000 │ ' 5540 ms' │ ' 66 ms' │ ' 59 ms' │ ' 1.12 x' │
1801
- │ Array_Object_Constrained │ 1000000 │ ' 5750 ms' │ ' 123 ms' │ ' 108 ms' │ ' 1.14 x' │
1802
- │ Array_Object_Recursive │ 1000000 │ ' 21842 ms' │ ' 1771 ms' │ ' 599 ms' │ ' 2.96 x' │
1803
- │ Array_Tuple_Primitive │ 1000000 │ ' 715 ms' │ ' 36 ms' │ ' 29 ms' │ ' 1.24 x' │
1804
- │ Array_Tuple_Object │ 1000000 │ ' 3131 ms' │ ' 63 ms' │ ' 50 ms' │ ' 1.26 x' │
1805
- │ Array_Composite_Intersect │ 1000000 │ ' 3064 ms' │ ' 44 ms' │ ' 35 ms' │ ' 1.26 x' │
1806
- │ Array_Composite_Union │ 1000000 │ ' 2172 ms' │ ' 65 ms' │ ' 31 ms' │ ' 2.10 x' │
1807
- │ Array_Math_Vector4 │ 1000000 │ ' 1032 ms' │ ' 37 ms' │ ' 24 ms' │ ' 1.54 x' │
1808
- │ Array_Math_Matrix4 │ 1000000 │ ' 4859 ms' │ ' 114 ms' │ ' 86 ms' │ ' 1.33 x' │
1778
+ │ Primitive_Number │ 1000000 │ ' 21 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1779
+ │ Primitive_String │ 1000000 │ ' 22 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1780
+ │ Primitive_String_Pattern │ 1000000 │ ' 164 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
1781
+ │ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1782
+ │ Primitive_Null │ 1000000 │ ' 19 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1783
+ │ Object_Unconstrained │ 1000000 │ ' 966 ms' │ ' 33 ms' │ ' 24 ms' │ ' 1.38 x' │
1784
+ │ Object_Constrained │ 1000000 │ ' 1275 ms' │ ' 52 ms' │ ' 42 ms' │ ' 1.24 x' │
1785
+ │ Object_Vector3 │ 1000000 │ ' 427 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1786
+ │ Object_Box3D │ 1000000 │ ' 2024 ms' │ ' 56 ms' │ ' 50 ms' │ ' 1.12 x' │
1787
+ │ Object_Recursive │ 1000000 │ ' 5263 ms' │ ' 358 ms' │ ' 164 ms' │ ' 2.18 x' │
1788
+ │ Tuple_Primitive │ 1000000 │ ' 157 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1789
+ │ Tuple_Object │ 1000000 │ ' 767 ms' │ ' 29 ms' │ ' 18 ms' │ ' 1.61 x' │
1790
+ │ Composite_Intersect │ 1000000 │ ' 769 ms' │ ' 26 ms' │ ' 15 ms' │ ' 1.73 x' │
1791
+ │ Composite_Union │ 1000000 │ ' 501 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
1792
+ │ Math_Vector4 │ 1000000 │ ' 250 ms' │ ' 23 ms' │ ' 11 ms' │ ' 2.09 x' │
1793
+ │ Math_Matrix4 │ 1000000 │ ' 1073 ms' │ ' 43 ms' │ ' 28 ms' │ ' 1.54 x' │
1794
+ │ Array_Primitive_Number │ 1000000 │ ' 264 ms' │ ' 21 ms' │ ' 12 ms' │ ' 1.75 x' │
1795
+ │ Array_Primitive_String │ 1000000 │ ' 242 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1796
+ │ Array_Primitive_Boolean │ 1000000 │ ' 151 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1797
+ │ Array_Object_Unconstrained │ 1000000 │ ' 5864 ms' │ ' 66 ms' │ ' 58 ms' │ ' 1.14 x' │
1798
+ │ Array_Object_Constrained │ 1000000 │ ' 5996 ms' │ ' 138 ms' │ ' 116 ms' │ ' 1.19 x' │
1799
+ │ Array_Object_Recursive │ 1000000 │ ' 22515 ms' │ ' 1625 ms' │ ' 585 ms' │ ' 2.78 x' │
1800
+ │ Array_Tuple_Primitive │ 1000000 │ ' 737 ms' │ ' 38 ms' │ ' 31 ms' │ ' 1.23 x' │
1801
+ │ Array_Tuple_Object │ 1000000 │ ' 3257 ms' │ ' 77 ms' │ ' 56 ms' │ ' 1.38 x' │
1802
+ │ Array_Composite_Intersect │ 1000000 │ ' 3119 ms' │ ' 49 ms' │ ' 38 ms' │ ' 1.29 x' │
1803
+ │ Array_Composite_Union │ 1000000 │ ' 2108 ms' │ ' 72 ms' │ ' 33 ms' │ ' 2.18 x' │
1804
+ │ Array_Math_Vector4 │ 1000000 │ ' 1078 ms' │ ' 38 ms' │ ' 26 ms' │ ' 1.46 x' │
1805
+ │ Array_Math_Matrix4 │ 1000000 │ ' 4967 ms' │ ' 126 ms' │ ' 88 ms' │ ' 1.43 x' │
1809
1806
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1810
1807
  ```
1811
1808
 
@@ -1819,12 +1816,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1819
1816
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1820
1817
  │ (index) │ Compiled │ Minified │ Compression │
1821
1818
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1822
- │ typebox/compiler │ '109.2 kb' │ ' 48.6 kb' │ '2.25 x' │
1823
- │ typebox/errors │ ' 55.0 kb' │ ' 25.1 kb' │ '2.19 x' │
1819
+ │ typebox/compiler │ '118.7 kb' │ ' 52.5 kb' │ '2.26 x' │
1820
+ │ typebox/errors │ ' 55.1 kb' │ ' 25.2 kb' │ '2.19 x' │
1824
1821
  │ typebox/system │ ' 4.6 kb' │ ' 2.0 kb' │ '2.31 x' │
1825
- │ typebox/type │ ' 82.9 kb' │ ' 34.9 kb' │ '2.38 x' │
1826
- │ typebox/value │ '144.2 kb' │ ' 61.5 kb' │ '2.34 x' │
1827
- │ typebox │ ' 82.9 kb' │ ' 34.9 kb' │ '2.37 x' │
1822
+ │ typebox/value │ '144.8 kb' │ ' 61.8 kb' │ '2.34 x' │
1823
+ │ typebox │ ' 87.7 kb' │ ' 36.7 kb' │ '2.39 x' │
1828
1824
  └──────────────────────┴────────────┴────────────┴─────────────┘
1829
1825
  ```
1830
1826
 
@@ -1,13 +0,0 @@
1
- import type { TSchema } from '../schema/index.mjs';
2
- import type { TProperties } from '../object/index.mjs';
3
- import { type TMappedResult } from '../mapped/index.mjs';
4
- import { type TExtends } from './extends.mjs';
5
- type MappedResultExtendsPropertyKeys<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema> = ({
6
- [K2 in keyof K]: TExtends<K[K2], U, L, R>;
7
- });
8
- declare function MappedResultExtendsPropertyKeys<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedResultExtendsPropertyKeys<K, U, L, R>;
9
- type MappedResultExtendsProperties<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema> = (MappedResultExtendsPropertyKeys<K['properties'], U, L, R>);
10
- declare function MappedResultExtendsProperties<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedResultExtendsProperties<K, U, L, R>;
11
- export type TExtendsMappedResultFromResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedResultExtendsProperties<T, U, L, R>> = (TMappedResult<P>);
12
- export declare function ExtendsMappedResultFromResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedResultExtendsProperties<T, U, L, R>>(T: T, U: U, L: L, R: R): TMappedResult<P>;
13
- export {};
@@ -1,14 +0,0 @@
1
- import { MappedResult } from '../mapped/index.mjs';
2
- import { Extends } from './extends.mjs';
3
- function MappedResultExtendsPropertyKeys(K, U, L, R) {
4
- return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
5
- return { ...Acc, [K2]: Extends(K[K2], U, L, R) };
6
- }, {});
7
- }
8
- function MappedResultExtendsProperties(K, U, L, R) {
9
- return MappedResultExtendsPropertyKeys(K.properties, U, L, R);
10
- }
11
- export function ExtendsMappedResultFromResult(T, U, L, R) {
12
- const P = MappedResultExtendsProperties(T, U, L, R);
13
- return MappedResult(P);
14
- }
@@ -1,17 +0,0 @@
1
- import type { TSchema } from '../schema/index.mjs';
2
- import type { TProperties } from '../object/index.mjs';
3
- import type { Assert } from '../helpers/index.mjs';
4
- import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
5
- import { TLiteral, TLiteralValue } from '../literal/index.mjs';
6
- import { type TExtends } from './extends.mjs';
7
- type MappedExtendsPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
8
- [_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
9
- };
10
- declare function MappedExtendsPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedExtendsPropertyKey<K, U, L, R>;
11
- type MappedExtendsPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? MappedExtendsPropertyKey<LK, U, L, R> & MappedExtendsPropertyKeys<RK, U, L, R> : {});
12
- declare function MappedExtendsPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema>(K: [...K], U: U, L: L, R: R): MappedExtendsPropertyKeys<K, U, L, R>;
13
- type MappedExtendsProperties<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (MappedExtendsPropertyKeys<K['keys'], U, L, R>);
14
- declare function MappedExtendsProperties<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedExtendsProperties<K, U, L, R>;
15
- export type TExtendsMappedResult<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedExtendsProperties<T, U, L, R>> = (TMappedResult<P>);
16
- export declare function ExtendsMappedResult<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedExtendsProperties<T, U, L, R>>(T: T, U: U, L: L, R: R): TMappedResult<P>;
17
- export {};
@@ -1,21 +0,0 @@
1
- import { MappedResult } from '../mapped/index.mjs';
2
- import { Literal } from '../literal/index.mjs';
3
- import { Extends } from './extends.mjs';
4
- function MappedExtendsPropertyKey(K, U, L, R) {
5
- return {
6
- [K]: Extends(Literal(K), U, L, R)
7
- };
8
- }
9
- function MappedExtendsPropertyKeys(K, U, L, R) {
10
- const [LK, ...RK] = K;
11
- return (K.length > 0
12
- ? { ...MappedExtendsPropertyKey(LK, U, L, R), ...MappedExtendsPropertyKeys(RK, U, L, R) }
13
- : {});
14
- }
15
- function MappedExtendsProperties(K, U, L, R) {
16
- return MappedExtendsPropertyKeys(K.keys, U, L, R);
17
- }
18
- export function ExtendsMappedResult(T, U, L, R) {
19
- const P = MappedExtendsProperties(T, U, L, R);
20
- return MappedResult(P);
21
- }
@@ -1,18 +0,0 @@
1
- import { IndexResult } from './indexed-result.mjs';
2
- import { MappedResult } from '../mapped/index.mjs';
3
- function MappedIndexPropertyKey(T, K) {
4
- return { [K]: IndexResult(T, [K]) };
5
- }
6
- function MappedIndexPropertyKeys(T, K) {
7
- const [L, ...R] = K;
8
- return (K.length > 0
9
- ? { ...MappedIndexPropertyKey(T, L), ...MappedIndexPropertyKeys(T, R) }
10
- : {});
11
- }
12
- function MappedIndexProperties(T, K) {
13
- return MappedIndexPropertyKeys(T, K.keys);
14
- }
15
- export function IndexMappedResult(T, K) {
16
- const P = MappedIndexProperties(T, K);
17
- return MappedResult(P);
18
- }
@@ -1,21 +0,0 @@
1
- import { MappedResult } from '../mapped/index.mjs';
2
- import { Intrinsic } from './intrinsic.mjs';
3
- import { Literal } from '../literal/index.mjs';
4
- function MappedIntrinsicPropertyKey(K, M) {
5
- return {
6
- [K]: Intrinsic(Literal(K), M)
7
- };
8
- }
9
- function MappedIntrinsicPropertyKeys(K, M) {
10
- const [L, ...R] = K;
11
- return (K.length > 0
12
- ? { ...MappedIntrinsicPropertyKey(L, M), ...MappedIntrinsicPropertyKeys(R, M) }
13
- : {});
14
- }
15
- function MappedIntrinsicProperties(T, M) {
16
- return MappedIntrinsicPropertyKeys(T['keys'], M);
17
- }
18
- export function IntrinsicMappedResult(T, M) {
19
- const P = MappedIntrinsicProperties(T, M);
20
- return MappedResult(P);
21
- }
@@ -1,15 +0,0 @@
1
- import type { TSchema } from '../schema/index.mjs';
2
- import type { TProperties } from '../object/index.mjs';
3
- import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
4
- import { type TOmit } from './omit.mjs';
5
- type MappedOmitPropertyKey<T extends TSchema, K extends PropertyKey> = {
6
- [_ in K]: TOmit<T, [K]>;
7
- };
8
- declare function MappedOmitPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): MappedOmitPropertyKey<T, K>;
9
- type MappedOmitPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? MappedOmitPropertyKey<T, LK> & MappedOmitPropertyKeys<T, RK> : {});
10
- declare function MappedOmitPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): MappedOmitPropertyKeys<T, K>;
11
- type MappedOmitProperties<T extends TSchema, K extends TMappedKey> = (MappedOmitPropertyKeys<T, K['keys']>);
12
- declare function MappedOmitProperties<T extends TSchema, K extends TMappedKey>(T: T, K: K): MappedOmitProperties<T, K>;
13
- export type TOmitMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedOmitProperties<T, K>> = (TMappedResult<P>);
14
- export declare function OmitMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedOmitProperties<T, K>>(T: T, K: K): TMappedResult<P>;
15
- export {};
@@ -1,20 +0,0 @@
1
- import { MappedResult } from '../mapped/index.mjs';
2
- import { Omit } from './omit.mjs';
3
- function MappedOmitPropertyKey(T, K) {
4
- return {
5
- [K]: Omit(T, [K])
6
- };
7
- }
8
- function MappedOmitPropertyKeys(T, K) {
9
- const [LK, ...RK] = K;
10
- return (K.length > 0
11
- ? { ...MappedOmitPropertyKey(T, LK), ...MappedOmitPropertyKeys(T, RK) }
12
- : {});
13
- }
14
- function MappedOmitProperties(T, K) {
15
- return MappedOmitPropertyKeys(T, K.keys);
16
- }
17
- export function OmitMappedResult(T, K) {
18
- const P = MappedOmitProperties(T, K);
19
- return MappedResult(P);
20
- }
@@ -1,15 +0,0 @@
1
- import type { TSchema } from '../schema/index.mjs';
2
- import type { TProperties } from '../object/index.mjs';
3
- import { type TMappedResult, type TMappedKey } from '../mapped/index.mjs';
4
- import { type TPick } from './pick.mjs';
5
- type MappedPickPropertyKey<T extends TSchema, K extends PropertyKey> = {
6
- [_ in K]: TPick<T, [K]>;
7
- };
8
- declare function MappedPickPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): MappedPickPropertyKey<T, K>;
9
- type MappedPickPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? MappedPickPropertyKey<T, LK> & MappedPickPropertyKeys<T, RK> : {});
10
- declare function MappedPickPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): MappedPickPropertyKeys<T, K>;
11
- type MappedPickProperties<T extends TSchema, K extends TMappedKey> = (MappedPickPropertyKeys<T, K['keys']>);
12
- declare function MappedPickProperties<T extends TSchema, K extends TMappedKey>(T: T, K: K): MappedPickProperties<T, K>;
13
- export type TPickMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedPickProperties<T, K>> = (TMappedResult<P>);
14
- export declare function PickMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedPickProperties<T, K>>(T: T, K: K): TMappedResult<P>;
15
- export {};
@@ -1,20 +0,0 @@
1
- import { MappedResult } from '../mapped/index.mjs';
2
- import { Pick } from './pick.mjs';
3
- function MappedPickPropertyKey(T, K) {
4
- return {
5
- [K]: Pick(T, [K])
6
- };
7
- }
8
- function MappedPickPropertyKeys(T, K) {
9
- const [LK, ...RK] = K;
10
- return (K.length > 0
11
- ? { ...MappedPickPropertyKey(T, LK), ...MappedPickPropertyKeys(T, RK) }
12
- : {});
13
- }
14
- function MappedPickProperties(T, K) {
15
- return MappedPickPropertyKeys(T, K.keys);
16
- }
17
- export function PickMappedResult(T, K) {
18
- const P = MappedPickProperties(T, K);
19
- return MappedResult(P);
20
- }
@@ -1,13 +0,0 @@
1
- import type { TSchema } from '../schema/index';
2
- import type { TProperties } from '../object/index';
3
- import { type TMappedResult } from '../mapped/index';
4
- import { type TExtends } from './extends';
5
- type MappedResultExtendsPropertyKeys<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema> = ({
6
- [K2 in keyof K]: TExtends<K[K2], U, L, R>;
7
- });
8
- declare function MappedResultExtendsPropertyKeys<K extends TProperties, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedResultExtendsPropertyKeys<K, U, L, R>;
9
- type MappedResultExtendsProperties<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema> = (MappedResultExtendsPropertyKeys<K['properties'], U, L, R>);
10
- declare function MappedResultExtendsProperties<K extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedResultExtendsProperties<K, U, L, R>;
11
- export type TExtendsMappedResultFromResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedResultExtendsProperties<T, U, L, R>> = (TMappedResult<P>);
12
- export declare function ExtendsMappedResultFromResult<T extends TMappedResult, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedResultExtendsProperties<T, U, L, R>>(T: T, U: U, L: L, R: R): TMappedResult<P>;
13
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtendsMappedResultFromResult = void 0;
4
- const index_1 = require("../mapped/index");
5
- const extends_1 = require("./extends");
6
- function MappedResultExtendsPropertyKeys(K, U, L, R) {
7
- return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
8
- return { ...Acc, [K2]: (0, extends_1.Extends)(K[K2], U, L, R) };
9
- }, {});
10
- }
11
- function MappedResultExtendsProperties(K, U, L, R) {
12
- return MappedResultExtendsPropertyKeys(K.properties, U, L, R);
13
- }
14
- function ExtendsMappedResultFromResult(T, U, L, R) {
15
- const P = MappedResultExtendsProperties(T, U, L, R);
16
- return (0, index_1.MappedResult)(P);
17
- }
18
- exports.ExtendsMappedResultFromResult = ExtendsMappedResultFromResult;
@@ -1,17 +0,0 @@
1
- import type { TSchema } from '../schema/index';
2
- import type { TProperties } from '../object/index';
3
- import type { Assert } from '../helpers/index';
4
- import { type TMappedResult, type TMappedKey } from '../mapped/index';
5
- import { TLiteral, TLiteralValue } from '../literal/index';
6
- import { type TExtends } from './extends';
7
- type MappedExtendsPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema> = {
8
- [_ in K]: TExtends<TLiteral<Assert<K, TLiteralValue>>, U, L, R>;
9
- };
10
- declare function MappedExtendsPropertyKey<K extends PropertyKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedExtendsPropertyKey<K, U, L, R>;
11
- type MappedExtendsPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? MappedExtendsPropertyKey<LK, U, L, R> & MappedExtendsPropertyKeys<RK, U, L, R> : {});
12
- declare function MappedExtendsPropertyKeys<K extends PropertyKey[], U extends TSchema, L extends TSchema, R extends TSchema>(K: [...K], U: U, L: L, R: R): MappedExtendsPropertyKeys<K, U, L, R>;
13
- type MappedExtendsProperties<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema> = (MappedExtendsPropertyKeys<K['keys'], U, L, R>);
14
- declare function MappedExtendsProperties<K extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema>(K: K, U: U, L: L, R: R): MappedExtendsProperties<K, U, L, R>;
15
- export type TExtendsMappedResult<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedExtendsProperties<T, U, L, R>> = (TMappedResult<P>);
16
- export declare function ExtendsMappedResult<T extends TMappedKey, U extends TSchema, L extends TSchema, R extends TSchema, P extends TProperties = MappedExtendsProperties<T, U, L, R>>(T: T, U: U, L: L, R: R): TMappedResult<P>;
17
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtendsMappedResult = void 0;
4
- const index_1 = require("../mapped/index");
5
- const index_2 = require("../literal/index");
6
- const extends_1 = require("./extends");
7
- function MappedExtendsPropertyKey(K, U, L, R) {
8
- return {
9
- [K]: (0, extends_1.Extends)((0, index_2.Literal)(K), U, L, R)
10
- };
11
- }
12
- function MappedExtendsPropertyKeys(K, U, L, R) {
13
- const [LK, ...RK] = K;
14
- return (K.length > 0
15
- ? { ...MappedExtendsPropertyKey(LK, U, L, R), ...MappedExtendsPropertyKeys(RK, U, L, R) }
16
- : {});
17
- }
18
- function MappedExtendsProperties(K, U, L, R) {
19
- return MappedExtendsPropertyKeys(K.keys, U, L, R);
20
- }
21
- function ExtendsMappedResult(T, U, L, R) {
22
- const P = MappedExtendsProperties(T, U, L, R);
23
- return (0, index_1.MappedResult)(P);
24
- }
25
- exports.ExtendsMappedResult = ExtendsMappedResult;