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

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 (128) hide show
  1. package/build/import/index.d.mts +5 -5
  2. package/build/import/index.mjs +3 -3
  3. package/build/import/type/composite/composite.d.mts +2 -2
  4. package/build/import/type/extends/extends-mapped-result-from-result.d.mts +13 -0
  5. package/build/import/type/extends/extends-mapped-result-from-result.mjs +14 -0
  6. package/build/import/type/extends/extends-mapped-result.d.mts +13 -9
  7. package/build/import/type/extends/extends-mapped-result.mjs +15 -8
  8. package/build/import/type/extends/extends.d.mts +4 -4
  9. package/build/import/type/extends/extends.mjs +4 -4
  10. package/build/import/type/extends/index.d.mts +1 -1
  11. package/build/import/type/extends/index.mjs +1 -1
  12. package/build/import/type/guard/type.d.mts +47 -46
  13. package/build/import/type/guard/type.mjs +294 -293
  14. package/build/import/type/indexed/index.d.mts +2 -2
  15. package/build/import/type/indexed/index.mjs +2 -2
  16. package/build/import/type/indexed/{indexed-mapped.d.mts → indexed-mapped-result.d.mts} +4 -4
  17. package/build/import/type/indexed/{indexed-mapped.mjs → indexed-mapped-result.mjs} +3 -3
  18. package/build/import/type/indexed/indexed-property-keys.d.mts +3 -3
  19. package/build/import/type/indexed/indexed-property-keys.mjs +2 -2
  20. package/build/import/type/indexed/{indexed-type.d.mts → indexed-result.d.mts} +2 -2
  21. package/build/import/type/indexed/{indexed-type.mjs → indexed-result.mjs} +1 -1
  22. package/build/import/type/indexed/indexed.d.mts +6 -6
  23. package/build/import/type/indexed/indexed.mjs +6 -6
  24. package/build/import/type/intrinsic/capitalize.d.mts +4 -0
  25. package/build/import/type/intrinsic/capitalize.mjs +5 -0
  26. package/build/import/type/intrinsic/index.d.mts +5 -0
  27. package/build/import/type/intrinsic/index.mjs +5 -0
  28. package/build/import/type/intrinsic/intrinsic-mapped-result.d.mts +15 -0
  29. package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +21 -0
  30. package/build/import/type/intrinsic/intrinsic.d.mts +9 -14
  31. package/build/import/type/intrinsic/intrinsic.mjs +10 -21
  32. package/build/import/type/intrinsic/lowercase.d.mts +4 -0
  33. package/build/import/type/intrinsic/lowercase.mjs +5 -0
  34. package/build/import/type/intrinsic/uncapitalize.d.mts +4 -0
  35. package/build/import/type/intrinsic/uncapitalize.mjs +5 -0
  36. package/build/import/type/intrinsic/uppercase.d.mts +4 -0
  37. package/build/import/type/intrinsic/uppercase.mjs +5 -0
  38. package/build/import/type/mapped/index.d.mts +2 -0
  39. package/build/import/type/mapped/index.mjs +2 -0
  40. package/build/import/type/mapped/mapped-key.d.mts +8 -0
  41. package/build/import/type/mapped/mapped-key.mjs +7 -0
  42. package/build/import/type/mapped/mapped-result.d.mts +9 -0
  43. package/build/import/type/mapped/mapped-result.mjs +7 -0
  44. package/build/import/type/mapped/mapped.d.mts +24 -31
  45. package/build/import/type/mapped/mapped.mjs +33 -36
  46. package/build/import/type/omit/index.d.mts +1 -0
  47. package/build/import/type/omit/index.mjs +1 -0
  48. package/build/import/type/omit/omit-mapped-result.d.mts +15 -0
  49. package/build/import/type/omit/omit-mapped-result.mjs +20 -0
  50. package/build/import/type/omit/omit.d.mts +5 -2
  51. package/build/import/type/omit/omit.mjs +12 -6
  52. package/build/import/type/pick/index.d.mts +1 -0
  53. package/build/import/type/pick/index.mjs +1 -0
  54. package/build/import/type/pick/pick-mapped-result.d.mts +15 -0
  55. package/build/import/type/pick/pick-mapped-result.mjs +20 -0
  56. package/build/import/type/pick/pick.d.mts +5 -2
  57. package/build/import/type/pick/pick.mjs +12 -6
  58. package/build/import/type/record/record.mjs +4 -4
  59. package/build/import/type/type/json.d.mts +15 -13
  60. package/build/import/value/transform/decode.mjs +2 -2
  61. package/build/import/value/transform/encode.mjs +2 -2
  62. package/build/require/index.d.ts +5 -5
  63. package/build/require/index.js +7 -6
  64. package/build/require/type/composite/composite.d.ts +2 -2
  65. package/build/require/type/extends/extends-mapped-result-from-result.d.ts +13 -0
  66. package/build/require/type/extends/extends-mapped-result-from-result.js +18 -0
  67. package/build/require/type/extends/extends-mapped-result.d.ts +13 -9
  68. package/build/require/type/extends/extends-mapped-result.js +17 -10
  69. package/build/require/type/extends/extends.d.ts +4 -4
  70. package/build/require/type/extends/extends.js +3 -3
  71. package/build/require/type/extends/index.d.ts +1 -1
  72. package/build/require/type/extends/index.js +1 -1
  73. package/build/require/type/guard/type.d.ts +47 -46
  74. package/build/require/type/guard/type.js +252 -250
  75. package/build/require/type/indexed/index.d.ts +2 -2
  76. package/build/require/type/indexed/index.js +2 -2
  77. package/build/require/type/indexed/{indexed-mapped.d.ts → indexed-mapped-result.d.ts} +4 -4
  78. package/build/require/type/indexed/{indexed-mapped.js → indexed-mapped-result.js} +5 -5
  79. package/build/require/type/indexed/indexed-property-keys.d.ts +3 -3
  80. package/build/require/type/indexed/indexed-property-keys.js +4 -4
  81. package/build/require/type/indexed/{indexed-type.d.ts → indexed-result.d.ts} +2 -2
  82. package/build/require/type/indexed/{indexed-type.js → indexed-result.js} +3 -3
  83. package/build/require/type/indexed/indexed.d.ts +6 -6
  84. package/build/require/type/indexed/indexed.js +5 -5
  85. package/build/require/type/intrinsic/capitalize.d.ts +4 -0
  86. package/build/require/type/intrinsic/capitalize.js +9 -0
  87. package/build/require/type/intrinsic/index.d.ts +5 -0
  88. package/build/require/type/intrinsic/index.js +5 -0
  89. package/build/require/type/intrinsic/intrinsic-mapped-result.d.ts +15 -0
  90. package/build/require/type/intrinsic/intrinsic-mapped-result.js +25 -0
  91. package/build/require/type/intrinsic/intrinsic.d.ts +9 -14
  92. package/build/require/type/intrinsic/intrinsic.js +10 -25
  93. package/build/require/type/intrinsic/lowercase.d.ts +4 -0
  94. package/build/require/type/intrinsic/lowercase.js +9 -0
  95. package/build/require/type/intrinsic/uncapitalize.d.ts +4 -0
  96. package/build/require/type/intrinsic/uncapitalize.js +9 -0
  97. package/build/require/type/intrinsic/uppercase.d.ts +4 -0
  98. package/build/require/type/intrinsic/uppercase.js +9 -0
  99. package/build/require/type/mapped/index.d.ts +2 -0
  100. package/build/require/type/mapped/index.js +2 -0
  101. package/build/require/type/mapped/mapped-key.d.ts +8 -0
  102. package/build/require/type/mapped/mapped-key.js +11 -0
  103. package/build/require/type/mapped/mapped-result.d.ts +9 -0
  104. package/build/require/type/mapped/mapped-result.js +11 -0
  105. package/build/require/type/mapped/mapped.d.ts +24 -31
  106. package/build/require/type/mapped/mapped.js +45 -52
  107. package/build/require/type/omit/index.d.ts +1 -0
  108. package/build/require/type/omit/index.js +1 -0
  109. package/build/require/type/omit/omit-mapped-result.d.ts +15 -0
  110. package/build/require/type/omit/omit-mapped-result.js +24 -0
  111. package/build/require/type/omit/omit.d.ts +5 -2
  112. package/build/require/type/omit/omit.js +10 -4
  113. package/build/require/type/pick/index.d.ts +1 -0
  114. package/build/require/type/pick/index.js +1 -0
  115. package/build/require/type/pick/pick-mapped-result.d.ts +15 -0
  116. package/build/require/type/pick/pick-mapped-result.js +24 -0
  117. package/build/require/type/pick/pick.d.ts +5 -2
  118. package/build/require/type/pick/pick.js +10 -4
  119. package/build/require/type/record/record.js +2 -2
  120. package/build/require/type/type/json.d.ts +15 -13
  121. package/build/require/value/transform/decode.js +1 -1
  122. package/build/require/value/transform/encode.js +1 -1
  123. package/package.json +1 -1
  124. package/readme.md +115 -47
  125. package/build/import/type/extends/extends-mapped.d.mts +0 -17
  126. package/build/import/type/extends/extends-mapped.mjs +0 -21
  127. package/build/require/type/extends/extends-mapped.d.ts +0 -17
  128. package/build/require/type/extends/extends-mapped.js +0 -25
package/readme.md CHANGED
@@ -67,15 +67,17 @@ License MIT
67
67
  - [JavaScript](#types-javascript)
68
68
  - [Options](#types-options)
69
69
  - [Properties](#types-properties)
70
+ - [Imports](#types-imports)
70
71
  - [Generics](#types-generics)
71
72
  - [References](#types-references)
72
73
  - [Recursive](#types-recursive)
73
74
  - [Conditional](#types-conditional)
75
+ - [Mapped](#types-mapped)
74
76
  - [Template Literal](#types-templateliteral)
75
77
  - [Indexed](#types-indexed)
76
- - [Rest](#types-rest)
77
- - [Transform](#types-transform)
78
78
  - [Intrinsic](#types-intrinsic)
79
+ - [Transform](#types-transform)
80
+ - [Rest](#types-rest)
79
81
  - [Guard](#types-guard)
80
82
  - [Unsafe](#types-unsafe)
81
83
  - [Strict](#types-strict)
@@ -375,8 +377,8 @@ The following table lists the supported Json types. These types are fully compat
375
377
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
376
378
  │ const T = Type.Extends( │ type T = │ const T = { │
377
379
  │ Type.String(), │ string extends number │ const: false, │
378
- │ Type.Number(), │ true : false │ type: 'boolean' │
379
- │ Type.Literal(true), │ │ } │
380
+ │ Type.Number(), │ ? true │ type: 'boolean' │
381
+ │ Type.Literal(true), │ : false │ } │
380
382
  │ Type.Literal(false) │ │ │
381
383
  │ ) │ │ │
382
384
  │ │ │ │
@@ -399,6 +401,20 @@ The following table lists the supported Json types. These types are fully compat
399
401
  │ ) │ │ │
400
402
  │ │ │ │
401
403
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
404
+ │ const T = Type.Mapped( │ type T = { │ const T = { │
405
+ │ Type.Union([ │ [_ in 'x' | 'y'] : number │ type: 'object', │
406
+ │ Type.Literal('x'), │ } │ required: ['x', 'y'], │
407
+ │ Type.Literal('y') │ │ properties: { │
408
+ │ ]), │ │ x: { │
409
+ │ () => Type.Number() │ │ type: 'number' │
410
+ │ ) │ │ }, │
411
+ │ │ │ y: { │
412
+ │ │ │ type: 'number' │
413
+ │ │ │ } │
414
+ │ │ │ } │
415
+ │ │ │ } │
416
+ │ │ │ │
417
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
402
418
  │ const U = Type.Union([ │ type U = 'open' | 'close' │ const T = { │
403
419
  │ Type.Literal('open'), │ │ type: 'string', │
404
420
  │ Type.Literal('close') │ type T = `on${U}` │ pattern: '^on(open|close)$' │
@@ -700,6 +716,32 @@ Object properties can be modified with Readonly and Optional. The following tabl
700
716
  │ │ │ │
701
717
  └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
702
718
  ```
719
+
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
+
703
745
  <a name='types-generics'></a>
704
746
 
705
747
  ### Generic Types
@@ -848,7 +890,7 @@ function test(node: Node) {
848
890
 
849
891
  ### Conditional Types
850
892
 
851
- TypeBox supports runtime conditional types with Extends. This type performs a structural assignability check for the first two arguments and will infer one of the second two arguments based on the result. The Extends type is designed to match the assignability rules of TypeScript conditional types. The conditional derived types Exclude and Extract are also supported.
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.
852
894
 
853
895
  ```typescript
854
896
  // Extends
@@ -889,11 +931,37 @@ const T = Type.Exclude( // const T: TUnion<[
889
931
  )
890
932
  ```
891
933
 
934
+ <a name='types-mapped'></a>
935
+
936
+ ### Mapped Types
937
+
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`.
939
+
940
+ ```typescript
941
+ const T = Type.Object({ // const T: TObject<{
942
+ x: Type.Number(), // x: TNumber,
943
+ y: Type.String(), // y: TString,
944
+ z: Type.Boolean() // z: TBoolean
945
+ }) // }>
946
+
947
+ const M = Type.Mapped(Type.KeyOf(T), K => { // type M = {
948
+ return Type.Union([ // [K in keyof T]: T[K] | null
949
+ Type.Index(T, K), // }
950
+ Type.Null() //
951
+ ]) // ... runtime mapped as
952
+ }) //
953
+ // const M: TObject<{
954
+ // x: TUnion<[TNumber, TNull]>,
955
+ // y: TUnion<[TString, TNull]>,
956
+ // z: TUnion<[TBoolean, TNull]>
957
+ // }>
958
+ ```
959
+
892
960
  <a name='types-templateliteral'></a>
893
961
 
894
962
  ### Template Literal Types
895
963
 
896
- TypeBox supports template literal types with 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 enable the template be checked via Json Schema. It also supports regular expression parsing, enabling template patterns to be used for generative types. The following shows both TypeScript and TypeBox usage.
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.
897
965
 
898
966
  ```typescript
899
967
  // TypeScript
@@ -928,7 +996,7 @@ const R = Type.Record(K, Type.String()) // const R: TObject<{
928
996
 
929
997
  ### Indexed Access Types
930
998
 
931
- TypeBox supports Indexed Access Types with 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.
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.
932
1000
 
933
1001
  ```typescript
934
1002
  const T = Type.Object({ // const T: TObject<{
@@ -951,23 +1019,35 @@ const C = Type.Index(T, Type.KeyOf(T)) // const C: TUnion<[
951
1019
  // ]>
952
1020
  ```
953
1021
 
954
- <a name='types-rest'></a>
1022
+ <a name='types-intrinsic'></a>
955
1023
 
956
- ### Rest Types
1024
+ ### Intrinsic Types
957
1025
 
958
- TypeBox provides the Rest type to uniformly extract variadic tuples from Intersect, Union and Tuple types. This type can be useful to remap variadic types into different forms. The following uses Rest to remap a Tuple into a Union.
1026
+ TypeBox supports the TypeScript Intrinsic String Manipulation types Uppercase, Lowercase, Capitalize and Uncapitalize. These types can be used to remap String Literal, Template Literal and Union of Literal types.
959
1027
 
960
1028
  ```typescript
961
- const T = Type.Tuple([ // const T: TTuple<[
962
- Type.String(), // TString,
963
- Type.Number() // TNumber
964
- ]) // ]>
1029
+ // TypeScript
965
1030
 
966
- const R = Type.Rest(T) // const R: [TString, TNumber]
1031
+ type A = Capitalize<'hello'> // type A = 'Hello'
1032
+ type B = Capitalize<'hello' | 'world'> // type C = 'Hello' | 'World'
1033
+ type C = Capitalize<`hello${1|2|3}`> // type B = 'Hello1' | 'Hello2' | 'Hello3'
967
1034
 
968
- const U = Type.Union(R) // const T: TUnion<[
969
- // TString,
970
- // TNumber
1035
+ // TypeBox
1036
+
1037
+ const A = Type.Capitalize(Type.Literal('hello')) // const A: TLiteral<'Hello'>
1038
+
1039
+ const B = Type.Capitalize(Type.Union([ // const B: TUnion<[
1040
+ Type.Literal('hello'), // TLiteral<'Hello'>,
1041
+ Type.Literal('world') // TLiteral<'World'>
1042
+ ])) // ]>
1043
+
1044
+ const C = Type.Capitalize( // const C: TTemplateLiteral<[
1045
+ Type.TemplateLiteral('hello${1|2|3}') // TLiteral<'Hello'>,
1046
+ ) // TUnion<[
1047
+ // TLiteral<'1'>,
1048
+ // TLiteral<'2'>,
1049
+ // TLiteral<'3'>
1050
+ // ]>
971
1051
  // ]>
972
1052
  ```
973
1053
 
@@ -1000,35 +1080,23 @@ type E = StaticEncode<typeof T> // type E = Array<number>
1000
1080
  type T = Static<typeof T> // type T = Array<number>
1001
1081
  ```
1002
1082
 
1003
- <a name='types-intrinsic'></a>
1083
+ <a name='types-rest'></a>
1004
1084
 
1005
- ### Intrinsic Types
1085
+ ### Rest Types
1006
1086
 
1007
- TypeBox supports the TypeScript Intrinsic String Manipulation types Uppercase, Lowercase, Capitalize and Uncapitalize. These types can be used to remap String Literal, TemplateLiteral and Union types.
1087
+ TypeBox provides the Rest type to uniformly extract variadic tuples from Intersect, Union and Tuple types. This type can be useful to remap variadic types into different forms. The following uses Rest to remap a Tuple into a Union.
1008
1088
 
1009
1089
  ```typescript
1010
- // TypeScript
1011
-
1012
- type A = Capitalize<'hello'> // type A = 'Hello'
1013
- type B = Capitalize<'hello' | 'world'> // type C = 'Hello' | 'World'
1014
- type C = Capitalize<`hello${1|2|3}`> // type B = 'Hello1' | 'Hello2' | 'Hello3'
1015
-
1016
- // TypeBox
1017
-
1018
- const A = Type.Capitalize(Type.Literal('hello')) // const A: TLiteral<'Hello'>
1090
+ const T = Type.Tuple([ // const T: TTuple<[
1091
+ Type.String(), // TString,
1092
+ Type.Number() // TNumber
1093
+ ]) // ]>
1019
1094
 
1020
- const B = Type.Capitalize(Type.Union([ // const B: TUnion<[
1021
- Type.Literal('hello'), // TLiteral<'Hello'>,
1022
- Type.Literal('world') // TLiteral<'World'>
1023
- ])) // ]>
1095
+ const R = Type.Rest(T) // const R: [TString, TNumber]
1024
1096
 
1025
- const C = Type.Capitalize( // const C: TTemplateLiteral<[
1026
- Type.TemplateLiteral('hello${1|2|3}') // TLiteral<'Hello'>,
1027
- ) // TUnion<[
1028
- // TLiteral<'1'>,
1029
- // TLiteral<'2'>,
1030
- // TLiteral<'3'>
1031
- // ]>
1097
+ const U = Type.Union(R) // const T: TUnion<[
1098
+ // TString,
1099
+ // TNumber
1032
1100
  // ]>
1033
1101
  ```
1034
1102
 
@@ -1751,12 +1819,12 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1751
1819
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1752
1820
  │ (index) │ Compiled │ Minified │ Compression │
1753
1821
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1754
- │ typebox/compiler │ '109.3 kb' │ ' 48.5 kb' │ '2.25 x' │
1755
- │ typebox/errors │ ' 54.8 kb' │ ' 24.9 kb' │ '2.20 x' │
1756
- │ typebox/system │ ' 12.1 kb' │ ' 6.1 kb' │ '1.98 x' │
1757
- │ typebox/type │ ' 77.8 kb' │ ' 32.8 kb' │ '2.37 x' │
1758
- │ typebox/value │ '143.7 kb' │ ' 61.2 kb' │ '2.35 x' │
1759
- │ typebox │ ' 77.9 kb' │ ' 32.8 kb' │ '2.37 x' │
1822
+ │ typebox/compiler │ '109.2 kb' │ ' 48.6 kb' │ '2.25 x' │
1823
+ │ typebox/errors │ ' 55.0 kb' │ ' 25.1 kb' │ '2.19 x' │
1824
+ │ 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' │
1760
1828
  └──────────────────────┴────────────┴────────────┴─────────────┘
1761
1829
  ```
1762
1830
 
@@ -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 MappedExtends<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 MappedExtends<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 MappedExtends(T, U, L, R) {
19
- const P = MappedExtendsProperties(T, U, L, R);
20
- return MappedResult(P);
21
- }
@@ -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 MappedExtends<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 MappedExtends<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.MappedExtends = 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 MappedExtends(T, U, L, R) {
22
- const P = MappedExtendsProperties(T, U, L, R);
23
- return (0, index_1.MappedResult)(P);
24
- }
25
- exports.MappedExtends = MappedExtends;