@sinclair/typebox 0.34.0 → 0.34.2
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.
- package/build/cjs/syntax/runtime.d.ts +4 -1
- package/build/cjs/syntax/runtime.js +3 -1
- package/build/cjs/syntax/static.d.ts +3 -3
- package/build/cjs/type/array/array.d.ts +1 -1
- package/build/cjs/type/awaited/awaited.d.ts +8 -3
- package/build/cjs/type/awaited/awaited.js +20 -20
- package/build/cjs/type/computed/computed.d.ts +9 -0
- package/build/cjs/type/computed/computed.js +10 -0
- package/build/cjs/type/computed/index.d.ts +1 -0
- package/build/cjs/type/computed/index.js +18 -0
- package/build/cjs/type/guard/kind.d.ts +9 -4
- package/build/cjs/type/guard/kind.js +10 -0
- package/build/cjs/type/guard/type.d.ts +6 -3
- package/build/cjs/type/guard/type.js +6 -0
- package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/indexed/indexed-from-mapped-key.js +10 -10
- package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/indexed/indexed-from-mapped-result.js +11 -10
- package/build/cjs/type/indexed/indexed-property-keys.d.ts +6 -6
- package/build/cjs/type/indexed/indexed-property-keys.js +14 -14
- package/build/cjs/type/indexed/indexed.d.ts +34 -20
- package/build/cjs/type/indexed/indexed.js +59 -46
- package/build/cjs/type/intersect/intersect-evaluated.d.ts +6 -6
- package/build/cjs/type/intersect/intersect-evaluated.js +16 -16
- package/build/cjs/type/intersect/intersect.d.ts +2 -2
- package/build/cjs/type/intersect/intersect.js +6 -6
- package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +6 -6
- package/build/cjs/type/keyof/keyof-from-mapped-result.js +10 -10
- package/build/cjs/type/keyof/keyof-property-keys.d.ts +7 -7
- package/build/cjs/type/keyof/keyof-property-keys.js +22 -22
- package/build/cjs/type/keyof/keyof.d.ts +11 -6
- package/build/cjs/type/keyof/keyof.js +22 -13
- package/build/cjs/type/module/compute.d.ts +54 -0
- package/build/cjs/type/module/compute.js +154 -0
- package/build/cjs/type/module/infer.d.ts +43 -0
- package/build/cjs/type/module/infer.js +3 -0
- package/build/cjs/type/module/module.d.ts +8 -52
- package/build/cjs/type/module/module.js +14 -11
- package/build/cjs/type/not/not.d.ts +1 -1
- package/build/cjs/type/not/not.js +2 -2
- package/build/cjs/type/omit/omit-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/omit/omit-from-mapped-key.js +10 -12
- package/build/cjs/type/omit/omit-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/omit/omit-from-mapped-result.js +10 -10
- package/build/cjs/type/omit/omit.d.ts +26 -14
- package/build/cjs/type/omit/omit.js +46 -35
- package/build/cjs/type/partial/partial.d.ts +11 -7
- package/build/cjs/type/partial/partial.js +36 -24
- package/build/cjs/type/pick/pick-from-mapped-key.d.ts +6 -6
- package/build/cjs/type/pick/pick-from-mapped-key.js +10 -10
- package/build/cjs/type/pick/pick-from-mapped-result.d.ts +5 -5
- package/build/cjs/type/pick/pick-from-mapped-result.js +10 -10
- package/build/cjs/type/pick/pick.d.ts +25 -15
- package/build/cjs/type/pick/pick.js +47 -36
- package/build/cjs/type/record/record.d.ts +4 -2
- package/build/cjs/type/record/record.js +31 -28
- package/build/cjs/type/required/required.d.ts +12 -8
- package/build/cjs/type/required/required.js +37 -25
- package/build/cjs/type/tuple/tuple.d.ts +1 -1
- package/build/cjs/type/tuple/tuple.js +4 -4
- package/build/cjs/type/type/javascript.d.ts +10 -10
- package/build/cjs/type/type/javascript.js +6 -6
- package/build/cjs/type/type/json.d.ts +41 -51
- package/build/cjs/type/type/json.js +40 -40
- package/build/cjs/type/union/union-evaluated.d.ts +6 -6
- package/build/cjs/type/union/union-evaluated.js +11 -10
- package/build/cjs/type/union/union.d.ts +1 -1
- package/build/cjs/type/union/union.js +4 -4
- package/build/cjs/value/check/check.js +3 -3
- package/build/cjs/value/transform/decode.js +7 -7
- package/build/cjs/value/transform/encode.js +7 -7
- package/build/cjs/value/transform/has.js +18 -18
- package/build/esm/syntax/runtime.d.mts +4 -1
- package/build/esm/syntax/runtime.mjs +3 -1
- package/build/esm/syntax/static.d.mts +3 -3
- package/build/esm/type/array/array.d.mts +1 -1
- package/build/esm/type/awaited/awaited.d.mts +8 -3
- package/build/esm/type/awaited/awaited.mjs +20 -20
- package/build/esm/type/computed/computed.d.mts +9 -0
- package/build/esm/type/computed/computed.mjs +6 -0
- package/build/esm/type/computed/index.d.mts +1 -0
- package/build/esm/type/computed/index.mjs +1 -0
- package/build/esm/type/guard/kind.d.mts +9 -4
- package/build/esm/type/guard/kind.mjs +8 -0
- package/build/esm/type/guard/type.d.mts +6 -3
- package/build/esm/type/guard/type.mjs +5 -0
- package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +6 -6
- package/build/esm/type/indexed/indexed-from-mapped-key.mjs +10 -10
- package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +5 -5
- package/build/esm/type/indexed/indexed-from-mapped-result.mjs +11 -10
- package/build/esm/type/indexed/indexed-property-keys.d.mts +6 -6
- package/build/esm/type/indexed/indexed-property-keys.mjs +14 -14
- package/build/esm/type/indexed/indexed.d.mts +34 -20
- package/build/esm/type/indexed/indexed.mjs +55 -42
- package/build/esm/type/intersect/intersect-evaluated.d.mts +6 -6
- package/build/esm/type/intersect/intersect-evaluated.mjs +16 -16
- package/build/esm/type/intersect/intersect.d.mts +2 -2
- package/build/esm/type/intersect/intersect.mjs +6 -6
- package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +6 -6
- package/build/esm/type/keyof/keyof-from-mapped-result.mjs +10 -10
- package/build/esm/type/keyof/keyof-property-keys.d.mts +7 -7
- package/build/esm/type/keyof/keyof-property-keys.mjs +22 -22
- package/build/esm/type/keyof/keyof.d.mts +11 -6
- package/build/esm/type/keyof/keyof.mjs +22 -13
- package/build/esm/type/module/compute.d.mts +54 -0
- package/build/esm/type/module/compute.mjs +148 -0
- package/build/esm/type/module/infer.d.mts +43 -0
- package/build/esm/type/module/infer.mjs +1 -0
- package/build/esm/type/module/module.d.mts +8 -52
- package/build/esm/type/module/module.mjs +14 -11
- package/build/esm/type/not/not.d.mts +1 -1
- package/build/esm/type/not/not.mjs +2 -2
- package/build/esm/type/omit/omit-from-mapped-key.d.mts +6 -6
- package/build/esm/type/omit/omit-from-mapped-key.mjs +10 -12
- package/build/esm/type/omit/omit-from-mapped-result.d.mts +5 -5
- package/build/esm/type/omit/omit-from-mapped-result.mjs +10 -10
- package/build/esm/type/omit/omit.d.mts +26 -14
- package/build/esm/type/omit/omit.mjs +43 -32
- package/build/esm/type/partial/partial.d.mts +11 -7
- package/build/esm/type/partial/partial.mjs +29 -17
- package/build/esm/type/pick/pick-from-mapped-key.d.mts +6 -6
- package/build/esm/type/pick/pick-from-mapped-key.mjs +10 -10
- package/build/esm/type/pick/pick-from-mapped-result.d.mts +5 -5
- package/build/esm/type/pick/pick-from-mapped-result.mjs +10 -10
- package/build/esm/type/pick/pick.d.mts +25 -15
- package/build/esm/type/pick/pick.mjs +43 -32
- package/build/esm/type/record/record.d.mts +4 -2
- package/build/esm/type/record/record.mjs +15 -12
- package/build/esm/type/required/required.d.mts +12 -8
- package/build/esm/type/required/required.mjs +33 -21
- package/build/esm/type/tuple/tuple.d.mts +1 -1
- package/build/esm/type/tuple/tuple.mjs +4 -4
- package/build/esm/type/type/javascript.d.mts +10 -10
- package/build/esm/type/type/javascript.mjs +6 -6
- package/build/esm/type/type/json.d.mts +41 -51
- package/build/esm/type/type/json.mjs +40 -40
- package/build/esm/type/union/union-evaluated.d.mts +6 -6
- package/build/esm/type/union/union-evaluated.mjs +11 -10
- package/build/esm/type/union/union.d.mts +1 -1
- package/build/esm/type/union/union.mjs +4 -4
- package/build/esm/value/check/check.mjs +2 -2
- package/build/esm/value/transform/decode.mjs +2 -2
- package/build/esm/value/transform/encode.mjs +2 -2
- package/build/esm/value/transform/has.mjs +2 -2
- package/package.json +1 -1
- 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
|
-
//
|
|
15
|
+
// KindGuard
|
|
16
16
|
// ------------------------------------------------------------------
|
|
17
|
-
import { IsSchema } from '../../type/guard/
|
|
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
|
-
//
|
|
12
|
+
// KindGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/
|
|
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
|
-
//
|
|
12
|
+
// KindGuard
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
import { IsTransform, IsSchema, IsUndefined } from '../../type/guard/
|
|
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
|
-
//
|
|
4
|
+
// KindGuard
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
|
-
import { IsTransform, IsSchema } from '../../type/guard/
|
|
6
|
+
import { IsTransform, IsSchema } from '../../type/guard/kind.mjs';
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// ValueGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
package/package.json
CHANGED
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://
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
1080
|
-
|
|
1081
|
-
export
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
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
|
|
1090
|
-
|
|
1091
|
-
|
|
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 │ '
|
|
1886
|
-
│ typebox/errors │ '
|
|
1887
|
-
│ typebox/syntax │ '
|
|
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 │ '
|
|
1890
|
-
│ typebox │ '
|
|
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
|
|