@sinclair/typebox 0.32.9 → 0.32.10
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/import/type/partial/partial.d.mts +2 -4
- package/build/import/type/partial/partial.mjs +3 -0
- package/build/import/type/required/required.d.mts +2 -3
- package/build/import/type/required/required.mjs +3 -0
- package/build/require/type/partial/partial.d.ts +2 -4
- package/build/require/type/partial/partial.js +3 -0
- package/build/require/type/required/required.d.ts +2 -3
- package/build/require/type/required/required.js +3 -0
- package/package.json +1 -1
|
@@ -9,13 +9,11 @@ import { type TObject, type TProperties } from '../object/index.mjs';
|
|
|
9
9
|
import { type TIntersect } from '../intersect/index.mjs';
|
|
10
10
|
import { type TUnion } from '../union/index.mjs';
|
|
11
11
|
import { type TPartialFromMappedResult } from './partial-from-mapped-result.mjs';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TPartial<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
|
|
18
|
-
export type TPartial<T extends TSchema> = PartialResolve<T>;
|
|
16
|
+
export type TPartial<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
19
17
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
20
18
|
export declare function Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
|
|
21
19
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
@@ -20,6 +20,9 @@ function FromProperties(T) {
|
|
|
20
20
|
return { ...Acc, [K]: Optional(T[K]) };
|
|
21
21
|
}, {});
|
|
22
22
|
}
|
|
23
|
+
// ------------------------------------------------------------------
|
|
24
|
+
// PartialResolve
|
|
25
|
+
// ------------------------------------------------------------------
|
|
23
26
|
// prettier-ignore
|
|
24
27
|
function PartialResolve(T) {
|
|
25
28
|
return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
|
|
@@ -9,12 +9,11 @@ import { type TIntersect } from '../intersect/index.mjs';
|
|
|
9
9
|
import { type TUnion } from '../union/index.mjs';
|
|
10
10
|
import { type TObject, type TProperties } from '../object/index.mjs';
|
|
11
11
|
import { type TRequiredFromMappedResult } from './required-from-mapped-result.mjs';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TRequired<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
export type TRequired<T extends TSchema> = TRequiredResolve<T>;
|
|
16
|
+
export type TRequired<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
18
17
|
/** `[Json]` Constructs a type where all properties are required */
|
|
19
18
|
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
20
19
|
/** `[Json]` Constructs a type where all properties are required */
|
|
@@ -19,6 +19,9 @@ function FromProperties(T) {
|
|
|
19
19
|
return { ...Acc, [K]: Discard(T[K], [OptionalKind]) };
|
|
20
20
|
}, {});
|
|
21
21
|
}
|
|
22
|
+
// ------------------------------------------------------------------
|
|
23
|
+
// RequiredResolve
|
|
24
|
+
// ------------------------------------------------------------------
|
|
22
25
|
// prettier-ignore
|
|
23
26
|
function RequiredResolve(T) {
|
|
24
27
|
return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
|
|
@@ -9,13 +9,11 @@ import { type TObject, type TProperties } from '../object/index';
|
|
|
9
9
|
import { type TIntersect } from '../intersect/index';
|
|
10
10
|
import { type TUnion } from '../union/index';
|
|
11
11
|
import { type TPartialFromMappedResult } from './partial-from-mapped-result';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TPartial<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
|
|
18
|
-
export type TPartial<T extends TSchema> = PartialResolve<T>;
|
|
16
|
+
export type TPartial<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TPartial<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
19
17
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
20
18
|
export declare function Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
|
|
21
19
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
@@ -24,6 +24,9 @@ function FromProperties(T) {
|
|
|
24
24
|
return { ...Acc, [K]: (0, index_1.Optional)(T[K]) };
|
|
25
25
|
}, {});
|
|
26
26
|
}
|
|
27
|
+
// ------------------------------------------------------------------
|
|
28
|
+
// PartialResolve
|
|
29
|
+
// ------------------------------------------------------------------
|
|
27
30
|
// prettier-ignore
|
|
28
31
|
function PartialResolve(T) {
|
|
29
32
|
return ((0, type_2.IsIntersect)(T) ? (0, index_3.Intersect)(FromRest(T.allOf)) :
|
|
@@ -9,12 +9,11 @@ import { type TIntersect } from '../intersect/index';
|
|
|
9
9
|
import { type TUnion } from '../union/index';
|
|
10
10
|
import { type TObject, type TProperties } from '../object/index';
|
|
11
11
|
import { type TRequiredFromMappedResult } from './required-from-mapped-result';
|
|
12
|
-
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc,
|
|
12
|
+
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TRequired<L>]> : Acc);
|
|
13
13
|
type TFromProperties<T extends TProperties> = Evaluate<{
|
|
14
14
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
17
|
-
export type TRequired<T extends TSchema> = TRequiredResolve<T>;
|
|
16
|
+
export type TRequired<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequired<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
|
|
18
17
|
/** `[Json]` Constructs a type where all properties are required */
|
|
19
18
|
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
20
19
|
/** `[Json]` Constructs a type where all properties are required */
|
|
@@ -23,6 +23,9 @@ function FromProperties(T) {
|
|
|
23
23
|
return { ...Acc, [K]: (0, index_5.Discard)(T[K], [index_4.OptionalKind]) };
|
|
24
24
|
}, {});
|
|
25
25
|
}
|
|
26
|
+
// ------------------------------------------------------------------
|
|
27
|
+
// RequiredResolve
|
|
28
|
+
// ------------------------------------------------------------------
|
|
26
29
|
// prettier-ignore
|
|
27
30
|
function RequiredResolve(T) {
|
|
28
31
|
return ((0, type_2.IsIntersect)(T) ? (0, index_1.Intersect)(FromRest(T.allOf)) :
|