@sinclair/typebox 0.34.0 → 0.34.1

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 (146) hide show
  1. package/build/cjs/syntax/runtime.d.ts +4 -1
  2. package/build/cjs/syntax/runtime.js +3 -1
  3. package/build/cjs/syntax/static.d.ts +3 -3
  4. package/build/cjs/type/array/array.d.ts +1 -1
  5. package/build/cjs/type/awaited/awaited.d.ts +8 -3
  6. package/build/cjs/type/awaited/awaited.js +20 -20
  7. package/build/cjs/type/computed/computed.d.ts +9 -0
  8. package/build/cjs/type/computed/computed.js +10 -0
  9. package/build/cjs/type/computed/index.d.ts +1 -0
  10. package/build/cjs/type/computed/index.js +18 -0
  11. package/build/cjs/type/guard/kind.d.ts +9 -4
  12. package/build/cjs/type/guard/kind.js +10 -0
  13. package/build/cjs/type/guard/type.d.ts +6 -3
  14. package/build/cjs/type/guard/type.js +6 -0
  15. package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +6 -6
  16. package/build/cjs/type/indexed/indexed-from-mapped-key.js +10 -10
  17. package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +5 -5
  18. package/build/cjs/type/indexed/indexed-from-mapped-result.js +11 -10
  19. package/build/cjs/type/indexed/indexed-property-keys.d.ts +6 -6
  20. package/build/cjs/type/indexed/indexed-property-keys.js +14 -14
  21. package/build/cjs/type/indexed/indexed.d.ts +34 -20
  22. package/build/cjs/type/indexed/indexed.js +59 -46
  23. package/build/cjs/type/intersect/intersect-evaluated.d.ts +6 -6
  24. package/build/cjs/type/intersect/intersect-evaluated.js +16 -16
  25. package/build/cjs/type/intersect/intersect.d.ts +2 -2
  26. package/build/cjs/type/intersect/intersect.js +6 -6
  27. package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +6 -6
  28. package/build/cjs/type/keyof/keyof-from-mapped-result.js +10 -10
  29. package/build/cjs/type/keyof/keyof-property-keys.d.ts +7 -7
  30. package/build/cjs/type/keyof/keyof-property-keys.js +22 -22
  31. package/build/cjs/type/keyof/keyof.d.ts +11 -6
  32. package/build/cjs/type/keyof/keyof.js +22 -13
  33. package/build/cjs/type/module/compute.d.ts +54 -0
  34. package/build/cjs/type/module/compute.js +154 -0
  35. package/build/cjs/type/module/infer.d.ts +43 -0
  36. package/build/cjs/type/module/infer.js +3 -0
  37. package/build/cjs/type/module/module.d.ts +8 -52
  38. package/build/cjs/type/module/module.js +14 -11
  39. package/build/cjs/type/not/not.d.ts +1 -1
  40. package/build/cjs/type/not/not.js +2 -2
  41. package/build/cjs/type/omit/omit-from-mapped-key.d.ts +6 -6
  42. package/build/cjs/type/omit/omit-from-mapped-key.js +10 -12
  43. package/build/cjs/type/omit/omit-from-mapped-result.d.ts +5 -5
  44. package/build/cjs/type/omit/omit-from-mapped-result.js +10 -10
  45. package/build/cjs/type/omit/omit.d.ts +26 -14
  46. package/build/cjs/type/omit/omit.js +46 -35
  47. package/build/cjs/type/partial/partial.d.ts +11 -7
  48. package/build/cjs/type/partial/partial.js +36 -24
  49. package/build/cjs/type/pick/pick-from-mapped-key.d.ts +6 -6
  50. package/build/cjs/type/pick/pick-from-mapped-key.js +10 -10
  51. package/build/cjs/type/pick/pick-from-mapped-result.d.ts +5 -5
  52. package/build/cjs/type/pick/pick-from-mapped-result.js +10 -10
  53. package/build/cjs/type/pick/pick.d.ts +25 -15
  54. package/build/cjs/type/pick/pick.js +47 -36
  55. package/build/cjs/type/record/record.d.ts +4 -2
  56. package/build/cjs/type/record/record.js +31 -28
  57. package/build/cjs/type/required/required.d.ts +12 -8
  58. package/build/cjs/type/required/required.js +37 -25
  59. package/build/cjs/type/tuple/tuple.d.ts +1 -1
  60. package/build/cjs/type/tuple/tuple.js +4 -4
  61. package/build/cjs/type/type/javascript.d.ts +10 -10
  62. package/build/cjs/type/type/javascript.js +6 -6
  63. package/build/cjs/type/type/json.d.ts +41 -51
  64. package/build/cjs/type/type/json.js +40 -40
  65. package/build/cjs/type/union/union-evaluated.d.ts +6 -6
  66. package/build/cjs/type/union/union-evaluated.js +11 -10
  67. package/build/cjs/type/union/union.d.ts +1 -1
  68. package/build/cjs/type/union/union.js +4 -4
  69. package/build/cjs/value/check/check.js +3 -3
  70. package/build/cjs/value/transform/decode.js +7 -7
  71. package/build/cjs/value/transform/encode.js +7 -7
  72. package/build/cjs/value/transform/has.js +18 -18
  73. package/build/esm/syntax/runtime.d.mts +4 -1
  74. package/build/esm/syntax/runtime.mjs +3 -1
  75. package/build/esm/syntax/static.d.mts +3 -3
  76. package/build/esm/type/array/array.d.mts +1 -1
  77. package/build/esm/type/awaited/awaited.d.mts +8 -3
  78. package/build/esm/type/awaited/awaited.mjs +20 -20
  79. package/build/esm/type/computed/computed.d.mts +9 -0
  80. package/build/esm/type/computed/computed.mjs +6 -0
  81. package/build/esm/type/computed/index.d.mts +1 -0
  82. package/build/esm/type/computed/index.mjs +1 -0
  83. package/build/esm/type/guard/kind.d.mts +9 -4
  84. package/build/esm/type/guard/kind.mjs +8 -0
  85. package/build/esm/type/guard/type.d.mts +6 -3
  86. package/build/esm/type/guard/type.mjs +5 -0
  87. package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +6 -6
  88. package/build/esm/type/indexed/indexed-from-mapped-key.mjs +10 -10
  89. package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +5 -5
  90. package/build/esm/type/indexed/indexed-from-mapped-result.mjs +11 -10
  91. package/build/esm/type/indexed/indexed-property-keys.d.mts +6 -6
  92. package/build/esm/type/indexed/indexed-property-keys.mjs +14 -14
  93. package/build/esm/type/indexed/indexed.d.mts +34 -20
  94. package/build/esm/type/indexed/indexed.mjs +55 -42
  95. package/build/esm/type/intersect/intersect-evaluated.d.mts +6 -6
  96. package/build/esm/type/intersect/intersect-evaluated.mjs +16 -16
  97. package/build/esm/type/intersect/intersect.d.mts +2 -2
  98. package/build/esm/type/intersect/intersect.mjs +6 -6
  99. package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +6 -6
  100. package/build/esm/type/keyof/keyof-from-mapped-result.mjs +10 -10
  101. package/build/esm/type/keyof/keyof-property-keys.d.mts +7 -7
  102. package/build/esm/type/keyof/keyof-property-keys.mjs +22 -22
  103. package/build/esm/type/keyof/keyof.d.mts +11 -6
  104. package/build/esm/type/keyof/keyof.mjs +22 -13
  105. package/build/esm/type/module/compute.d.mts +54 -0
  106. package/build/esm/type/module/compute.mjs +148 -0
  107. package/build/esm/type/module/infer.d.mts +43 -0
  108. package/build/esm/type/module/infer.mjs +1 -0
  109. package/build/esm/type/module/module.d.mts +8 -52
  110. package/build/esm/type/module/module.mjs +14 -11
  111. package/build/esm/type/not/not.d.mts +1 -1
  112. package/build/esm/type/not/not.mjs +2 -2
  113. package/build/esm/type/omit/omit-from-mapped-key.d.mts +6 -6
  114. package/build/esm/type/omit/omit-from-mapped-key.mjs +10 -12
  115. package/build/esm/type/omit/omit-from-mapped-result.d.mts +5 -5
  116. package/build/esm/type/omit/omit-from-mapped-result.mjs +10 -10
  117. package/build/esm/type/omit/omit.d.mts +26 -14
  118. package/build/esm/type/omit/omit.mjs +43 -32
  119. package/build/esm/type/partial/partial.d.mts +11 -7
  120. package/build/esm/type/partial/partial.mjs +29 -17
  121. package/build/esm/type/pick/pick-from-mapped-key.d.mts +6 -6
  122. package/build/esm/type/pick/pick-from-mapped-key.mjs +10 -10
  123. package/build/esm/type/pick/pick-from-mapped-result.d.mts +5 -5
  124. package/build/esm/type/pick/pick-from-mapped-result.mjs +10 -10
  125. package/build/esm/type/pick/pick.d.mts +25 -15
  126. package/build/esm/type/pick/pick.mjs +43 -32
  127. package/build/esm/type/record/record.d.mts +4 -2
  128. package/build/esm/type/record/record.mjs +15 -12
  129. package/build/esm/type/required/required.d.mts +12 -8
  130. package/build/esm/type/required/required.mjs +33 -21
  131. package/build/esm/type/tuple/tuple.d.mts +1 -1
  132. package/build/esm/type/tuple/tuple.mjs +4 -4
  133. package/build/esm/type/type/javascript.d.mts +10 -10
  134. package/build/esm/type/type/javascript.mjs +6 -6
  135. package/build/esm/type/type/json.d.mts +41 -51
  136. package/build/esm/type/type/json.mjs +40 -40
  137. package/build/esm/type/union/union-evaluated.d.mts +6 -6
  138. package/build/esm/type/union/union-evaluated.mjs +11 -10
  139. package/build/esm/type/union/union.d.mts +1 -1
  140. package/build/esm/type/union/union.mjs +4 -4
  141. package/build/esm/value/check/check.mjs +2 -2
  142. package/build/esm/value/transform/decode.mjs +2 -2
  143. package/build/esm/value/transform/encode.mjs +2 -2
  144. package/build/esm/value/transform/has.mjs +2 -2
  145. package/package.json +1 -1
  146. package/readme.md +30 -19
@@ -12,9 +12,9 @@ import { Never } from '../../type/never/index.mjs';
12
12
  // ------------------------------------------------------------------
13
13
  import { IsArray, IsUint8Array, IsDate, IsPromise, IsFunction, IsAsyncIterator, IsIterator, IsBoolean, IsNumber, IsBigInt, IsString, IsSymbol, IsInteger, IsNull, IsUndefined } from '../guard/index.mjs';
14
14
  // ------------------------------------------------------------------
15
- // TypeGuard
15
+ // KindGuard
16
16
  // ------------------------------------------------------------------
17
- import { IsSchema } from '../../type/guard/type.mjs';
17
+ import { IsSchema } from '../../type/guard/kind.mjs';
18
18
  // ------------------------------------------------------------------
19
19
  // Errors
20
20
  // ------------------------------------------------------------------
@@ -9,9 +9,9 @@ import { Check } from '../check/index.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  import { HasPropertyKey, IsObject, IsArray, IsValueType, IsUndefined as IsUndefinedValue } from '../guard/index.mjs';
11
11
  // ------------------------------------------------------------------
12
- // TypeGuard
12
+ // KindGuard
13
13
  // ------------------------------------------------------------------
14
- import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/type.mjs';
14
+ import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/kind.mjs';
15
15
  // ------------------------------------------------------------------
16
16
  // Errors
17
17
  // ------------------------------------------------------------------
@@ -9,9 +9,9 @@ import { Check } from '../check/index.mjs';
9
9
  // ------------------------------------------------------------------
10
10
  import { HasPropertyKey, IsObject, IsArray, IsValueType, IsUndefined as IsUndefinedValue } from '../guard/index.mjs';
11
11
  // ------------------------------------------------------------------
12
- // TypeGuard
12
+ // KindGuard
13
13
  // ------------------------------------------------------------------
14
- import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/type.mjs';
14
+ import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/kind.mjs';
15
15
  // ------------------------------------------------------------------
16
16
  // Errors
17
17
  // ------------------------------------------------------------------
@@ -1,9 +1,9 @@
1
1
  import { Deref, Pushref } from '../deref/index.mjs';
2
2
  import { Kind } from '../../type/symbols/index.mjs';
3
3
  // ------------------------------------------------------------------
4
- // TypeGuard
4
+ // KindGuard
5
5
  // ------------------------------------------------------------------
6
- import { IsTransform, IsSchema } from '../../type/guard/type.mjs';
6
+ import { IsTransform, IsSchema } from '../../type/guard/kind.mjs';
7
7
  // ------------------------------------------------------------------
8
8
  // ValueGuard
9
9
  // ------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/readme.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <p>Json Schema Type Builder with Static Type Resolution for TypeScript</p>
6
6
 
7
- <img src="https://github.com/sinclairzx81/typebox/blob/master/typebox.png?raw=true" />
7
+ <img src="https://raw.githubusercontent.com/sinclairzx81/typebox/refs/heads/master/typebox.png" />
8
8
 
9
9
  <br />
10
10
  <br />
@@ -777,7 +777,8 @@ type T = Static<typeof T> // type T = string | null
777
777
  TypeBox Modules are containers for related types. They function as namespaces and enable internal types to reference each other via string references. Modules support both singular and mutually recursive types. They provide a mechanism to create circular types irrespective of the order in which types are defined.
778
778
 
779
779
  ```typescript
780
- // The following creates a circular recursive type.
780
+
781
+ // The following creates a Module of circular recursive Types.
781
782
 
782
783
  const Module = Type.Module({
783
784
  A: Type.Object({
@@ -791,7 +792,7 @@ const Module = Type.Module({
791
792
  }),
792
793
  })
793
794
 
794
- // Module types must be imported before use.
795
+ // Module Types must be imported before use.
795
796
 
796
797
  const A = Module.Import('A') // const A: TImport<{...}, 'A'>
797
798
 
@@ -1073,22 +1074,32 @@ const T = Type.Object({ // const T: TObject<{
1073
1074
 
1074
1075
  ### Module
1075
1076
 
1076
- Syntax Types support Module parsing, which is useful for processing multiple TypeScript types. Module parsing supports type alias and interface definitions. Generics are currently unsupported as of 0.34.0.
1077
+ Syntax Types also support Module parsing. This can provide a more terse syntax for creating Module definitions, but comes with an inference performance cost. Module parsing supports interface and type alias definitions. Generics types are currently unsupported.
1077
1078
 
1078
1079
  ```typescript
1079
- const Foo = Parse(`module Foo {
1080
-
1081
- export type A = string
1082
-
1083
- export type B = number
1084
-
1085
- export type C = A | B
1080
+ const Module = Parse(`module {
1081
+
1082
+ export interface User {
1083
+ id: string
1084
+ name: string
1085
+ email: string
1086
+ }
1087
+
1088
+ export type PartialUser = (
1089
+ Pick<User, 'id'> &
1090
+ Partial<Omit<User, 'id'>>
1091
+ )
1086
1092
 
1087
1093
  }`)
1088
1094
 
1089
- const C = Foo.Import('C') // const C: TImport<{
1090
- // ...
1091
- // }, 'C'>
1095
+ const PartialUser = Module.Import('PartialUser') // TImport<{...}, 'PartialUser'>
1096
+
1097
+ type PartialUser = Static<typeof PartialUser> // type PartialUser = {
1098
+ // id: string,
1099
+ // } & {
1100
+ // name?: string,
1101
+ // email?: string,
1102
+ // }
1092
1103
  ```
1093
1104
 
1094
1105
  <a name='syntax-context'></a>
@@ -1882,12 +1893,12 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1882
1893
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1883
1894
  │ (index) │ Compiled │ Minified │ Compression │
1884
1895
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1885
- │ typebox/compiler │ '121.7 kb' │ ' 53.4 kb' │ '2.28 x' │
1886
- │ typebox/errors │ ' 75.3 kb' │ ' 33.4 kb' │ '2.25 x' │
1887
- │ typebox/syntax │ '120.1 kb' │ ' 50.5 kb' │ '2.38 x' │
1896
+ │ typebox/compiler │ '122.4 kb' │ ' 53.4 kb' │ '2.29 x' │
1897
+ │ typebox/errors │ ' 67.6 kb' │ ' 29.6 kb' │ '2.28 x' │
1898
+ │ typebox/syntax │ '132.9 kb' │ ' 54.2 kb' │ '2.45 x' │
1888
1899
  │ typebox/system │ ' 7.4 kb' │ ' 3.2 kb' │ '2.33 x' │
1889
- │ typebox/value │ '160.3 kb' │ ' 67.4 kb' │ '2.38 x' │
1890
- │ typebox │ ' 96.2 kb' │ ' 40.2 kb' │ '2.39 x' │
1900
+ │ typebox/value │ '150.1 kb' │ ' 62.2 kb' │ '2.41 x' │
1901
+ │ typebox │ '106.8 kb' │ ' 43.2 kb' │ '2.47 x' │
1891
1902
  └──────────────────────┴────────────┴────────────┴─────────────┘
1892
1903
  ```
1893
1904