@sinclair/typebox 0.34.21 → 0.34.22

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.
@@ -10,6 +10,15 @@ import { type TObject, type TProperties } from '../object/index';
10
10
  import { type TIntersect } from '../intersect/index';
11
11
  import { type TUnion } from '../union/index';
12
12
  import { type TRef } from '../ref/index';
13
+ import { type TBigInt } from '../bigint/index';
14
+ import { type TBoolean } from '../boolean/index';
15
+ import { type TInteger } from '../integer/index';
16
+ import { type TLiteral } from '../literal/index';
17
+ import { type TNull } from '../null/index';
18
+ import { type TNumber } from '../number/index';
19
+ import { type TString } from '../string/index';
20
+ import { type TSymbol } from '../symbol/index';
21
+ import { type TUndefined } from '../undefined/index';
13
22
  import { type TPartialFromMappedResult } from './partial-from-mapped-result';
14
23
  type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'Partial', [TComputed<Target, Parameters>]>>;
15
24
  type TFromRef<Ref extends string> = Ensure<TComputed<'Partial', [TRef<Ref>]>>;
@@ -18,7 +27,7 @@ type TFromProperties<Properties extends TProperties> = Evaluate<{
18
27
  }>;
19
28
  type TFromObject<Type extends TObject, Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties>)>>;
20
29
  type TFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Result, TPartial<L>]> : Result);
21
- export type TPartial<T extends TSchema> = (T extends TRecursive<infer Type extends TSchema> ? TRecursive<TPartial<Type>> : T extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : T extends TRef<infer Ref extends string> ? TFromRef<Ref> : T extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : T extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : T extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : TObject<{}>);
30
+ export type TPartial<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TPartial<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
22
31
  /** `[Json]` Constructs a type where all properties are optional */
23
32
  export declare function Partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
24
33
  /** `[Json]` Constructs a type where all properties are optional */
@@ -13,9 +13,9 @@ const index_7 = require("../discard/index");
13
13
  const index_8 = require("../symbols/index");
14
14
  const partial_from_mapped_result_1 = require("./partial-from-mapped-result");
15
15
  // ------------------------------------------------------------------
16
- // TypeGuard
16
+ // KindGuard
17
17
  // ------------------------------------------------------------------
18
- const kind_1 = require("../guard/kind");
18
+ const KindGuard = require("../guard/kind");
19
19
  // prettier-ignore
20
20
  function FromComputed(target, parameters) {
21
21
  return (0, index_1.Computed)('Partial', [(0, index_1.Computed)(target, parameters)]);
@@ -32,9 +32,9 @@ function FromProperties(properties) {
32
32
  return partialProperties;
33
33
  }
34
34
  // prettier-ignore
35
- function FromObject(T) {
36
- const options = (0, index_7.Discard)(T, [index_8.TransformKind, '$id', 'required', 'properties']);
37
- const properties = FromProperties(T['properties']);
35
+ function FromObject(type) {
36
+ const options = (0, index_7.Discard)(type, [index_8.TransformKind, '$id', 'required', 'properties']);
37
+ const properties = FromProperties(type['properties']);
38
38
  return (0, index_3.Object)(properties, options);
39
39
  }
40
40
  // prettier-ignore
@@ -46,16 +46,29 @@ function FromRest(types) {
46
46
  // ------------------------------------------------------------------
47
47
  // prettier-ignore
48
48
  function PartialResolve(type) {
49
- return ((0, kind_1.IsComputed)(type) ? FromComputed(type.target, type.parameters) :
50
- (0, kind_1.IsRef)(type) ? FromRef(type.$ref) :
51
- (0, kind_1.IsIntersect)(type) ? (0, index_4.Intersect)(FromRest(type.allOf)) :
52
- (0, kind_1.IsUnion)(type) ? (0, index_5.Union)(FromRest(type.anyOf)) :
53
- (0, kind_1.IsObject)(type) ? FromObject(type) :
54
- (0, index_3.Object)({}));
49
+ return (
50
+ // Mappable
51
+ KindGuard.IsComputed(type) ? FromComputed(type.target, type.parameters) :
52
+ KindGuard.IsRef(type) ? FromRef(type.$ref) :
53
+ KindGuard.IsIntersect(type) ? (0, index_4.Intersect)(FromRest(type.allOf)) :
54
+ KindGuard.IsUnion(type) ? (0, index_5.Union)(FromRest(type.anyOf)) :
55
+ KindGuard.IsObject(type) ? FromObject(type) :
56
+ // Intrinsic
57
+ KindGuard.IsBigInt(type) ? type :
58
+ KindGuard.IsBoolean(type) ? type :
59
+ KindGuard.IsInteger(type) ? type :
60
+ KindGuard.IsLiteral(type) ? type :
61
+ KindGuard.IsNull(type) ? type :
62
+ KindGuard.IsNumber(type) ? type :
63
+ KindGuard.IsString(type) ? type :
64
+ KindGuard.IsSymbol(type) ? type :
65
+ KindGuard.IsUndefined(type) ? type :
66
+ // Passthrough
67
+ (0, index_3.Object)({}));
55
68
  }
56
69
  /** `[Json]` Constructs a type where all properties are optional */
57
70
  function Partial(type, options) {
58
- if ((0, kind_1.IsMappedResult)(type)) {
71
+ if (KindGuard.IsMappedResult(type)) {
59
72
  return (0, partial_from_mapped_result_1.PartialFromMappedResult)(type, options);
60
73
  }
61
74
  else {
@@ -10,6 +10,15 @@ import { type TObject, type TProperties } from '../object/index';
10
10
  import { type TIntersect } from '../intersect/index';
11
11
  import { type TUnion } from '../union/index';
12
12
  import { type TRef } from '../ref/index';
13
+ import { type TBigInt } from '../bigint/index';
14
+ import { type TBoolean } from '../boolean/index';
15
+ import { type TInteger } from '../integer/index';
16
+ import { type TLiteral } from '../literal/index';
17
+ import { type TNull } from '../null/index';
18
+ import { type TNumber } from '../number/index';
19
+ import { type TString } from '../string/index';
20
+ import { type TSymbol } from '../symbol/index';
21
+ import { type TUndefined } from '../undefined/index';
13
22
  import { type TRequiredFromMappedResult } from './required-from-mapped-result';
14
23
  type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'Required', [TComputed<Target, Parameters>]>>;
15
24
  type TFromRef<Ref extends string> = Ensure<TComputed<'Required', [TRef<Ref>]>>;
@@ -18,7 +27,7 @@ type TFromProperties<Properties extends TProperties> = Evaluate<{
18
27
  }>;
19
28
  type TFromObject<Type extends TObject, Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties>)>>;
20
29
  type TFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Result, TRequired<L>]> : Result);
21
- export type TRequired<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TRequired<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : TObject<{}>);
30
+ export type TRequired<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TRequired<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
22
31
  /** `[Json]` Constructs a type where all properties are required */
23
32
  export declare function Required<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TRequiredFromMappedResult<MappedResult>;
24
33
  /** `[Json]` Constructs a type where all properties are required */
@@ -14,7 +14,7 @@ const required_from_mapped_result_1 = require("./required-from-mapped-result");
14
14
  // ------------------------------------------------------------------
15
15
  // TypeGuard
16
16
  // ------------------------------------------------------------------
17
- const kind_1 = require("../guard/kind");
17
+ const KindGuard = require("../guard/kind");
18
18
  // prettier-ignore
19
19
  function FromComputed(target, parameters) {
20
20
  return (0, index_1.Computed)('Required', [(0, index_1.Computed)(target, parameters)]);
@@ -45,16 +45,29 @@ function FromRest(types) {
45
45
  // ------------------------------------------------------------------
46
46
  // prettier-ignore
47
47
  function RequiredResolve(type) {
48
- return ((0, kind_1.IsComputed)(type) ? FromComputed(type.target, type.parameters) :
49
- (0, kind_1.IsRef)(type) ? FromRef(type.$ref) :
50
- (0, kind_1.IsIntersect)(type) ? (0, index_3.Intersect)(FromRest(type.allOf)) :
51
- (0, kind_1.IsUnion)(type) ? (0, index_4.Union)(FromRest(type.anyOf)) :
52
- (0, kind_1.IsObject)(type) ? FromObject(type) :
53
- (0, index_2.Object)({}));
48
+ return (
49
+ // Mappable
50
+ KindGuard.IsComputed(type) ? FromComputed(type.target, type.parameters) :
51
+ KindGuard.IsRef(type) ? FromRef(type.$ref) :
52
+ KindGuard.IsIntersect(type) ? (0, index_3.Intersect)(FromRest(type.allOf)) :
53
+ KindGuard.IsUnion(type) ? (0, index_4.Union)(FromRest(type.anyOf)) :
54
+ KindGuard.IsObject(type) ? FromObject(type) :
55
+ // Intrinsic
56
+ KindGuard.IsBigInt(type) ? type :
57
+ KindGuard.IsBoolean(type) ? type :
58
+ KindGuard.IsInteger(type) ? type :
59
+ KindGuard.IsLiteral(type) ? type :
60
+ KindGuard.IsNull(type) ? type :
61
+ KindGuard.IsNumber(type) ? type :
62
+ KindGuard.IsString(type) ? type :
63
+ KindGuard.IsSymbol(type) ? type :
64
+ KindGuard.IsUndefined(type) ? type :
65
+ // Passthrough
66
+ (0, index_2.Object)({}));
54
67
  }
55
68
  /** `[Json]` Constructs a type where all properties are required */
56
69
  function Required(type, options) {
57
- if ((0, kind_1.IsMappedResult)(type)) {
70
+ if (KindGuard.IsMappedResult(type)) {
58
71
  return (0, required_from_mapped_result_1.RequiredFromMappedResult)(type, options);
59
72
  }
60
73
  else {
@@ -10,6 +10,15 @@ import { type TObject, type TProperties } from '../object/index.mjs';
10
10
  import { type TIntersect } from '../intersect/index.mjs';
11
11
  import { type TUnion } from '../union/index.mjs';
12
12
  import { type TRef } from '../ref/index.mjs';
13
+ import { type TBigInt } from '../bigint/index.mjs';
14
+ import { type TBoolean } from '../boolean/index.mjs';
15
+ import { type TInteger } from '../integer/index.mjs';
16
+ import { type TLiteral } from '../literal/index.mjs';
17
+ import { type TNull } from '../null/index.mjs';
18
+ import { type TNumber } from '../number/index.mjs';
19
+ import { type TString } from '../string/index.mjs';
20
+ import { type TSymbol } from '../symbol/index.mjs';
21
+ import { type TUndefined } from '../undefined/index.mjs';
13
22
  import { type TPartialFromMappedResult } from './partial-from-mapped-result.mjs';
14
23
  type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'Partial', [TComputed<Target, Parameters>]>>;
15
24
  type TFromRef<Ref extends string> = Ensure<TComputed<'Partial', [TRef<Ref>]>>;
@@ -18,7 +27,7 @@ type TFromProperties<Properties extends TProperties> = Evaluate<{
18
27
  }>;
19
28
  type TFromObject<Type extends TObject, Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties>)>>;
20
29
  type TFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Result, TPartial<L>]> : Result);
21
- export type TPartial<T extends TSchema> = (T extends TRecursive<infer Type extends TSchema> ? TRecursive<TPartial<Type>> : T extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : T extends TRef<infer Ref extends string> ? TFromRef<Ref> : T extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : T extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : T extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : TObject<{}>);
30
+ export type TPartial<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TPartial<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
22
31
  /** `[Json]` Constructs a type where all properties are optional */
23
32
  export declare function Partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
24
33
  /** `[Json]` Constructs a type where all properties are optional */
@@ -9,9 +9,9 @@ import { Discard } from '../discard/index.mjs';
9
9
  import { TransformKind } from '../symbols/index.mjs';
10
10
  import { PartialFromMappedResult } from './partial-from-mapped-result.mjs';
11
11
  // ------------------------------------------------------------------
12
- // TypeGuard
12
+ // KindGuard
13
13
  // ------------------------------------------------------------------
14
- import { IsMappedResult, IsIntersect, IsUnion, IsObject, IsRef, IsComputed } from '../guard/kind.mjs';
14
+ import * as KindGuard from '../guard/kind.mjs';
15
15
  // prettier-ignore
16
16
  function FromComputed(target, parameters) {
17
17
  return Computed('Partial', [Computed(target, parameters)]);
@@ -28,9 +28,9 @@ function FromProperties(properties) {
28
28
  return partialProperties;
29
29
  }
30
30
  // prettier-ignore
31
- function FromObject(T) {
32
- const options = Discard(T, [TransformKind, '$id', 'required', 'properties']);
33
- const properties = FromProperties(T['properties']);
31
+ function FromObject(type) {
32
+ const options = Discard(type, [TransformKind, '$id', 'required', 'properties']);
33
+ const properties = FromProperties(type['properties']);
34
34
  return Object(properties, options);
35
35
  }
36
36
  // prettier-ignore
@@ -42,16 +42,29 @@ function FromRest(types) {
42
42
  // ------------------------------------------------------------------
43
43
  // prettier-ignore
44
44
  function PartialResolve(type) {
45
- return (IsComputed(type) ? FromComputed(type.target, type.parameters) :
46
- IsRef(type) ? FromRef(type.$ref) :
47
- IsIntersect(type) ? Intersect(FromRest(type.allOf)) :
48
- IsUnion(type) ? Union(FromRest(type.anyOf)) :
49
- IsObject(type) ? FromObject(type) :
50
- Object({}));
45
+ return (
46
+ // Mappable
47
+ KindGuard.IsComputed(type) ? FromComputed(type.target, type.parameters) :
48
+ KindGuard.IsRef(type) ? FromRef(type.$ref) :
49
+ KindGuard.IsIntersect(type) ? Intersect(FromRest(type.allOf)) :
50
+ KindGuard.IsUnion(type) ? Union(FromRest(type.anyOf)) :
51
+ KindGuard.IsObject(type) ? FromObject(type) :
52
+ // Intrinsic
53
+ KindGuard.IsBigInt(type) ? type :
54
+ KindGuard.IsBoolean(type) ? type :
55
+ KindGuard.IsInteger(type) ? type :
56
+ KindGuard.IsLiteral(type) ? type :
57
+ KindGuard.IsNull(type) ? type :
58
+ KindGuard.IsNumber(type) ? type :
59
+ KindGuard.IsString(type) ? type :
60
+ KindGuard.IsSymbol(type) ? type :
61
+ KindGuard.IsUndefined(type) ? type :
62
+ // Passthrough
63
+ Object({}));
51
64
  }
52
65
  /** `[Json]` Constructs a type where all properties are optional */
53
66
  export function Partial(type, options) {
54
- if (IsMappedResult(type)) {
67
+ if (KindGuard.IsMappedResult(type)) {
55
68
  return PartialFromMappedResult(type, options);
56
69
  }
57
70
  else {
@@ -10,6 +10,15 @@ import { type TObject, type TProperties } from '../object/index.mjs';
10
10
  import { type TIntersect } from '../intersect/index.mjs';
11
11
  import { type TUnion } from '../union/index.mjs';
12
12
  import { type TRef } from '../ref/index.mjs';
13
+ import { type TBigInt } from '../bigint/index.mjs';
14
+ import { type TBoolean } from '../boolean/index.mjs';
15
+ import { type TInteger } from '../integer/index.mjs';
16
+ import { type TLiteral } from '../literal/index.mjs';
17
+ import { type TNull } from '../null/index.mjs';
18
+ import { type TNumber } from '../number/index.mjs';
19
+ import { type TString } from '../string/index.mjs';
20
+ import { type TSymbol } from '../symbol/index.mjs';
21
+ import { type TUndefined } from '../undefined/index.mjs';
13
22
  import { type TRequiredFromMappedResult } from './required-from-mapped-result.mjs';
14
23
  type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'Required', [TComputed<Target, Parameters>]>>;
15
24
  type TFromRef<Ref extends string> = Ensure<TComputed<'Required', [TRef<Ref>]>>;
@@ -18,7 +27,7 @@ type TFromProperties<Properties extends TProperties> = Evaluate<{
18
27
  }>;
19
28
  type TFromObject<Type extends TObject, Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties>)>>;
20
29
  type TFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Result, TRequired<L>]> : Result);
21
- export type TRequired<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TRequired<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : TObject<{}>);
30
+ export type TRequired<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TRecursive<TRequired<Type>> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<Target, Parameters> : Type extends TRef<infer Ref extends string> ? TFromRef<Ref> : Type extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromRest<Types>> : Type extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromRest<Types>> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<TObject<Properties>> : Type extends TBigInt ? Type : Type extends TBoolean ? Type : Type extends TInteger ? Type : Type extends TLiteral ? Type : Type extends TNull ? Type : Type extends TNumber ? Type : Type extends TString ? Type : Type extends TSymbol ? Type : Type extends TUndefined ? Type : TObject<{}>);
22
31
  /** `[Json]` Constructs a type where all properties are required */
23
32
  export declare function Required<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TRequiredFromMappedResult<MappedResult>;
24
33
  /** `[Json]` Constructs a type where all properties are required */
@@ -10,7 +10,7 @@ import { RequiredFromMappedResult } from './required-from-mapped-result.mjs';
10
10
  // ------------------------------------------------------------------
11
11
  // TypeGuard
12
12
  // ------------------------------------------------------------------
13
- import { IsMappedResult, IsIntersect, IsUnion, IsObject, IsRef, IsComputed } from '../guard/kind.mjs';
13
+ import * as KindGuard from '../guard/kind.mjs';
14
14
  // prettier-ignore
15
15
  function FromComputed(target, parameters) {
16
16
  return Computed('Required', [Computed(target, parameters)]);
@@ -41,16 +41,29 @@ function FromRest(types) {
41
41
  // ------------------------------------------------------------------
42
42
  // prettier-ignore
43
43
  function RequiredResolve(type) {
44
- return (IsComputed(type) ? FromComputed(type.target, type.parameters) :
45
- IsRef(type) ? FromRef(type.$ref) :
46
- IsIntersect(type) ? Intersect(FromRest(type.allOf)) :
47
- IsUnion(type) ? Union(FromRest(type.anyOf)) :
48
- IsObject(type) ? FromObject(type) :
49
- Object({}));
44
+ return (
45
+ // Mappable
46
+ KindGuard.IsComputed(type) ? FromComputed(type.target, type.parameters) :
47
+ KindGuard.IsRef(type) ? FromRef(type.$ref) :
48
+ KindGuard.IsIntersect(type) ? Intersect(FromRest(type.allOf)) :
49
+ KindGuard.IsUnion(type) ? Union(FromRest(type.anyOf)) :
50
+ KindGuard.IsObject(type) ? FromObject(type) :
51
+ // Intrinsic
52
+ KindGuard.IsBigInt(type) ? type :
53
+ KindGuard.IsBoolean(type) ? type :
54
+ KindGuard.IsInteger(type) ? type :
55
+ KindGuard.IsLiteral(type) ? type :
56
+ KindGuard.IsNull(type) ? type :
57
+ KindGuard.IsNumber(type) ? type :
58
+ KindGuard.IsString(type) ? type :
59
+ KindGuard.IsSymbol(type) ? type :
60
+ KindGuard.IsUndefined(type) ? type :
61
+ // Passthrough
62
+ Object({}));
50
63
  }
51
64
  /** `[Json]` Constructs a type where all properties are required */
52
65
  export function Required(type, options) {
53
- if (IsMappedResult(type)) {
66
+ if (KindGuard.IsMappedResult(type)) {
54
67
  return RequiredFromMappedResult(type, options);
55
68
  }
56
69
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.34.21",
3
+ "version": "0.34.22",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",