@sinclair/typebox 0.33.22 → 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.
- package/build/cjs/compiler/compiler.d.ts +2 -2
- package/build/cjs/compiler/compiler.js +13 -2
- package/build/cjs/errors/errors.js +7 -0
- package/build/cjs/index.d.ts +1 -2
- package/build/cjs/index.js +1 -2
- package/build/cjs/syntax/parse.d.ts +14 -15
- package/build/cjs/syntax/parse.js +6 -5
- package/build/cjs/syntax/runtime.d.ts +20 -4
- package/build/cjs/syntax/runtime.js +183 -28
- package/build/cjs/syntax/static.d.ts +107 -23
- 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/{deref → computed}/index.js +1 -1
- package/build/cjs/type/guard/kind.d.ts +12 -4
- package/build/cjs/type/guard/kind.js +15 -0
- package/build/cjs/type/guard/type.d.ts +9 -3
- package/build/cjs/type/guard/type.js +19 -0
- package/build/cjs/type/index.d.ts +1 -2
- package/build/cjs/type/index.js +1 -2
- 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/index.d.ts +1 -0
- package/build/cjs/type/{strict → module}/index.js +1 -1
- 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 +27 -0
- package/build/cjs/type/module/module.js +37 -0
- 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/ref/ref.d.ts +4 -7
- package/build/cjs/type/ref/ref.js +3 -11
- package/build/cjs/type/required/required.d.ts +12 -8
- package/build/cjs/type/required/required.js +37 -25
- package/build/cjs/type/static/static.d.ts +1 -1
- 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 +45 -68
- package/build/cjs/type/type/json.js +82 -98
- package/build/cjs/type/type/type.d.ts +1 -2
- package/build/cjs/type/type/type.js +55 -57
- 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/cast/cast.js +8 -1
- package/build/cjs/value/check/check.js +11 -4
- package/build/cjs/value/clean/clean.js +8 -1
- package/build/cjs/value/convert/convert.js +7 -0
- package/build/cjs/value/create/create.js +7 -0
- package/build/cjs/value/default/default.js +7 -0
- package/build/cjs/value/transform/decode.js +18 -7
- package/build/cjs/value/transform/encode.js +18 -7
- package/build/cjs/value/transform/has.js +18 -18
- package/build/esm/compiler/compiler.d.mts +2 -2
- package/build/esm/compiler/compiler.mjs +13 -2
- package/build/esm/errors/errors.mjs +7 -0
- package/build/esm/index.d.mts +1 -2
- package/build/esm/index.mjs +1 -2
- package/build/esm/syntax/parse.d.mts +14 -15
- package/build/esm/syntax/parse.mjs +6 -5
- package/build/esm/syntax/runtime.d.mts +20 -4
- package/build/esm/syntax/runtime.mjs +183 -28
- package/build/esm/syntax/static.d.mts +107 -23
- 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 +12 -4
- package/build/esm/type/guard/kind.mjs +12 -0
- package/build/esm/type/guard/type.d.mts +9 -3
- package/build/esm/type/guard/type.mjs +17 -0
- package/build/esm/type/index.d.mts +1 -2
- package/build/esm/type/index.mjs +1 -2
- 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/index.d.mts +1 -0
- package/build/esm/type/module/index.mjs +1 -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 +27 -0
- package/build/esm/type/module/module.mjs +31 -0
- 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/ref/ref.d.mts +4 -7
- package/build/esm/type/ref/ref.mjs +3 -11
- package/build/esm/type/required/required.d.mts +12 -8
- package/build/esm/type/required/required.mjs +33 -21
- package/build/esm/type/static/static.d.mts +1 -1
- 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 +45 -68
- package/build/esm/type/type/json.mjs +47 -63
- package/build/esm/type/type/type.d.mts +1 -2
- package/build/esm/type/type/type.mjs +1 -2
- 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/cast/cast.mjs +9 -2
- package/build/esm/value/check/check.mjs +11 -4
- package/build/esm/value/clean/clean.mjs +9 -2
- package/build/esm/value/convert/convert.mjs +7 -0
- package/build/esm/value/create/create.mjs +7 -0
- package/build/esm/value/default/default.mjs +7 -0
- package/build/esm/value/transform/decode.mjs +13 -2
- package/build/esm/value/transform/encode.mjs +13 -2
- package/build/esm/value/transform/has.mjs +2 -2
- package/package.json +1 -1
- package/readme.md +230 -97
- package/build/cjs/type/deref/deref.d.ts +0 -22
- package/build/cjs/type/deref/deref.js +0 -106
- package/build/cjs/type/deref/index.d.ts +0 -1
- package/build/cjs/type/strict/index.d.ts +0 -1
- package/build/cjs/type/strict/strict.d.ts +0 -12
- package/build/cjs/type/strict/strict.js +0 -16
- package/build/esm/type/deref/deref.d.mts +0 -22
- package/build/esm/type/deref/deref.mjs +0 -102
- package/build/esm/type/deref/index.d.mts +0 -1
- package/build/esm/type/deref/index.mjs +0 -1
- package/build/esm/type/strict/index.d.mts +0 -1
- package/build/esm/type/strict/index.mjs +0 -1
- package/build/esm/type/strict/strict.d.mts +0 -12
- package/build/esm/type/strict/strict.mjs +0 -12
|
@@ -4,61 +4,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Omit = Omit;
|
|
5
5
|
const type_1 = require("../create/type");
|
|
6
6
|
const discard_1 = require("../discard/discard");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
7
|
+
const symbols_1 = require("../symbols/symbols");
|
|
8
|
+
const index_1 = require("../computed/index");
|
|
9
|
+
const index_2 = require("../literal/index");
|
|
10
|
+
const index_3 = require("../indexed/index");
|
|
11
|
+
const index_4 = require("../intersect/index");
|
|
12
|
+
const index_5 = require("../union/index");
|
|
13
|
+
const index_6 = require("../object/index");
|
|
14
|
+
// ------------------------------------------------------------------
|
|
15
|
+
// Mapped
|
|
16
|
+
// ------------------------------------------------------------------
|
|
11
17
|
const omit_from_mapped_key_1 = require("./omit-from-mapped-key");
|
|
12
18
|
const omit_from_mapped_result_1 = require("./omit-from-mapped-result");
|
|
13
|
-
const symbols_1 = require("../symbols/symbols");
|
|
14
19
|
// ------------------------------------------------------------------
|
|
15
20
|
// TypeGuard
|
|
16
21
|
// ------------------------------------------------------------------
|
|
17
22
|
const kind_1 = require("../guard/kind");
|
|
23
|
+
const value_1 = require("../guard/value");
|
|
18
24
|
// prettier-ignore
|
|
19
|
-
function FromIntersect(
|
|
20
|
-
return
|
|
25
|
+
function FromIntersect(types, propertyKeys) {
|
|
26
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
21
27
|
}
|
|
22
28
|
// prettier-ignore
|
|
23
|
-
function FromUnion(
|
|
24
|
-
return
|
|
29
|
+
function FromUnion(types, propertyKeys) {
|
|
30
|
+
return types.map((type) => OmitResolve(type, propertyKeys));
|
|
25
31
|
}
|
|
26
32
|
// ------------------------------------------------------------------
|
|
27
33
|
// FromProperty
|
|
28
34
|
// ------------------------------------------------------------------
|
|
29
35
|
// prettier-ignore
|
|
30
|
-
function FromProperty(
|
|
31
|
-
const { [
|
|
36
|
+
function FromProperty(properties, key) {
|
|
37
|
+
const { [key]: _, ...R } = properties;
|
|
32
38
|
return R;
|
|
33
39
|
}
|
|
34
40
|
// prettier-ignore
|
|
35
|
-
function FromProperties(
|
|
36
|
-
return
|
|
41
|
+
function FromProperties(properties, propertyKeys) {
|
|
42
|
+
return propertyKeys.reduce((T, K2) => FromProperty(T, K2), properties);
|
|
37
43
|
}
|
|
38
44
|
// prettier-ignore
|
|
39
|
-
function FromObject(
|
|
40
|
-
const options = (0, discard_1.Discard)(
|
|
41
|
-
const
|
|
42
|
-
return (0,
|
|
45
|
+
function FromObject(properties, propertyKeys) {
|
|
46
|
+
const options = (0, discard_1.Discard)(properties, [symbols_1.TransformKind, '$id', 'required', 'properties']);
|
|
47
|
+
const omittedProperties = FromProperties(properties['properties'], propertyKeys);
|
|
48
|
+
return (0, index_6.Object)(omittedProperties, options);
|
|
49
|
+
}
|
|
50
|
+
// prettier-ignore
|
|
51
|
+
function UnionFromPropertyKeys(propertyKeys) {
|
|
52
|
+
const result = propertyKeys.reduce((result, key) => (0, kind_1.IsLiteralValue)(key) ? [...result, (0, index_2.Literal)(key)] : result, []);
|
|
53
|
+
return (0, index_5.Union)(result);
|
|
43
54
|
}
|
|
44
|
-
// ------------------------------------------------------------------
|
|
45
|
-
// OmitResolve
|
|
46
|
-
// ------------------------------------------------------------------
|
|
47
55
|
// prettier-ignore
|
|
48
|
-
function OmitResolve(
|
|
49
|
-
return ((0, kind_1.IsIntersect)(
|
|
50
|
-
(0, kind_1.IsUnion)(
|
|
51
|
-
(0, kind_1.IsObject)(
|
|
52
|
-
(0,
|
|
56
|
+
function OmitResolve(properties, propertyKeys) {
|
|
57
|
+
return ((0, kind_1.IsIntersect)(properties) ? (0, index_4.Intersect)(FromIntersect(properties.allOf, propertyKeys)) :
|
|
58
|
+
(0, kind_1.IsUnion)(properties) ? (0, index_5.Union)(FromUnion(properties.anyOf, propertyKeys)) :
|
|
59
|
+
(0, kind_1.IsObject)(properties) ? FromObject(properties, propertyKeys) :
|
|
60
|
+
(0, index_6.Object)({}));
|
|
53
61
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
63
|
+
// prettier-ignore
|
|
64
|
+
function Omit(type, key, options) {
|
|
65
|
+
const typeKey = (0, value_1.IsArray)(key) ? UnionFromPropertyKeys(key) : key;
|
|
66
|
+
const propertyKeys = (0, kind_1.IsSchema)(key) ? (0, index_3.IndexPropertyKeys)(key) : key;
|
|
67
|
+
const isTypeRef = (0, kind_1.IsRef)(type);
|
|
68
|
+
const isKeyRef = (0, kind_1.IsRef)(key);
|
|
69
|
+
return ((0, kind_1.IsMappedResult)(type) ? (0, omit_from_mapped_result_1.OmitFromMappedResult)(type, propertyKeys, options) :
|
|
70
|
+
(0, kind_1.IsMappedKey)(key) ? (0, omit_from_mapped_key_1.OmitFromMappedKey)(type, key, options) :
|
|
71
|
+
(isTypeRef && isKeyRef) ? (0, index_1.Computed)('Omit', [type, typeKey], options) :
|
|
72
|
+
(!isTypeRef && isKeyRef) ? (0, index_1.Computed)('Omit', [type, typeKey], options) :
|
|
73
|
+
(isTypeRef && !isKeyRef) ? (0, index_1.Computed)('Omit', [type, typeKey], options) :
|
|
74
|
+
(0, type_1.CreateType)({ ...OmitResolve(type, propertyKeys), ...options }));
|
|
64
75
|
}
|
|
@@ -2,21 +2,25 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Evaluate, Ensure } from '../helpers/index';
|
|
3
3
|
import type { TMappedResult } from '../mapped/index';
|
|
4
4
|
import { type TReadonlyOptional } from '../readonly-optional/index';
|
|
5
|
+
import { type TComputed } from '../computed/index';
|
|
5
6
|
import { type TOptional } from '../optional/index';
|
|
6
7
|
import { type TReadonly } from '../readonly/index';
|
|
7
8
|
import { type TRecursive } from '../recursive/index';
|
|
8
9
|
import { type TObject, type TProperties } from '../object/index';
|
|
9
10
|
import { type TIntersect } from '../intersect/index';
|
|
10
11
|
import { type TUnion } from '../union/index';
|
|
12
|
+
import { type TRef } from '../ref/index';
|
|
11
13
|
import { type TPartialFromMappedResult } from './partial-from-mapped-result';
|
|
12
|
-
type
|
|
13
|
-
type
|
|
14
|
-
|
|
14
|
+
type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'Partial', [TComputed<Target, Parameters>]>>;
|
|
15
|
+
type TFromRef<Ref extends string> = Ensure<TComputed<'Partial', [TRef<Ref>]>>;
|
|
16
|
+
type TFromProperties<Properties extends TProperties> = Evaluate<{
|
|
17
|
+
[K in keyof Properties]: Properties[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : Properties[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : Properties[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<Properties[K]>;
|
|
15
18
|
}>;
|
|
16
|
-
type TFromObject<
|
|
17
|
-
|
|
19
|
+
type TFromObject<Type extends TObject, Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties>)>>;
|
|
20
|
+
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<{}>);
|
|
18
22
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
19
|
-
export declare function Partial<
|
|
23
|
+
export declare function Partial<MappedResult extends TMappedResult>(type: MappedResult, options?: SchemaOptions): TPartialFromMappedResult<MappedResult>;
|
|
20
24
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
21
|
-
export declare function Partial<
|
|
25
|
+
export declare function Partial<Type extends TSchema>(type: Type, options?: SchemaOptions): TPartial<Type>;
|
|
22
26
|
export {};
|
|
@@ -3,51 +3,63 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Partial = Partial;
|
|
5
5
|
const type_1 = require("../create/type");
|
|
6
|
-
const index_1 = require("../
|
|
7
|
-
const index_2 = require("../
|
|
8
|
-
const index_3 = require("../
|
|
9
|
-
const index_4 = require("../
|
|
10
|
-
const index_5 = require("../
|
|
11
|
-
const index_6 = require("../
|
|
6
|
+
const index_1 = require("../computed/index");
|
|
7
|
+
const index_2 = require("../optional/index");
|
|
8
|
+
const index_3 = require("../object/index");
|
|
9
|
+
const index_4 = require("../intersect/index");
|
|
10
|
+
const index_5 = require("../union/index");
|
|
11
|
+
const index_6 = require("../ref/index");
|
|
12
|
+
const index_7 = require("../discard/index");
|
|
13
|
+
const index_8 = require("../symbols/index");
|
|
12
14
|
const partial_from_mapped_result_1 = require("./partial-from-mapped-result");
|
|
13
15
|
// ------------------------------------------------------------------
|
|
14
16
|
// TypeGuard
|
|
15
17
|
// ------------------------------------------------------------------
|
|
16
18
|
const kind_1 = require("../guard/kind");
|
|
17
19
|
// prettier-ignore
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
+
function FromComputed(target, parameters) {
|
|
21
|
+
return (0, index_1.Computed)('Partial', [(0, index_1.Computed)(target, parameters)]);
|
|
20
22
|
}
|
|
21
23
|
// prettier-ignore
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function FromRef($ref) {
|
|
25
|
+
return (0, index_1.Computed)('Partial', [(0, index_6.Ref)($ref)]);
|
|
26
|
+
}
|
|
27
|
+
// prettier-ignore
|
|
28
|
+
function FromProperties(properties) {
|
|
29
|
+
const partialProperties = {};
|
|
30
|
+
for (const K of globalThis.Object.getOwnPropertyNames(properties))
|
|
31
|
+
partialProperties[K] = (0, index_2.Optional)(properties[K]);
|
|
32
|
+
return partialProperties;
|
|
27
33
|
}
|
|
28
34
|
// prettier-ignore
|
|
29
35
|
function FromObject(T) {
|
|
30
|
-
const options = (0,
|
|
36
|
+
const options = (0, index_7.Discard)(T, [index_8.TransformKind, '$id', 'required', 'properties']);
|
|
31
37
|
const properties = FromProperties(T['properties']);
|
|
32
|
-
return (0,
|
|
38
|
+
return (0, index_3.Object)(properties, options);
|
|
39
|
+
}
|
|
40
|
+
// prettier-ignore
|
|
41
|
+
function FromRest(types) {
|
|
42
|
+
return types.map(type => PartialResolve(type));
|
|
33
43
|
}
|
|
34
44
|
// ------------------------------------------------------------------
|
|
35
45
|
// PartialResolve
|
|
36
46
|
// ------------------------------------------------------------------
|
|
37
47
|
// prettier-ignore
|
|
38
|
-
function PartialResolve(
|
|
39
|
-
return ((0, kind_1.
|
|
40
|
-
(0, kind_1.
|
|
41
|
-
(0, kind_1.
|
|
42
|
-
(0,
|
|
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)({}));
|
|
43
55
|
}
|
|
44
56
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
45
|
-
function Partial(
|
|
46
|
-
if ((0, kind_1.IsMappedResult)(
|
|
47
|
-
return (0, partial_from_mapped_result_1.PartialFromMappedResult)(
|
|
57
|
+
function Partial(type, options) {
|
|
58
|
+
if ((0, kind_1.IsMappedResult)(type)) {
|
|
59
|
+
return (0, partial_from_mapped_result_1.PartialFromMappedResult)(type, options);
|
|
48
60
|
}
|
|
49
61
|
else {
|
|
50
62
|
// special: mapping types require overridable options
|
|
51
|
-
return (0, type_1.CreateType)({ ...PartialResolve(
|
|
63
|
+
return (0, type_1.CreateType)({ ...PartialResolve(type), ...options });
|
|
52
64
|
}
|
|
53
65
|
}
|
|
@@ -2,11 +2,11 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { TProperties } from '../object/index';
|
|
3
3
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
4
4
|
import { type TPick } from './pick';
|
|
5
|
-
type TFromPropertyKey<
|
|
6
|
-
[_ in
|
|
5
|
+
type TFromPropertyKey<Type extends TSchema, Key extends PropertyKey> = {
|
|
6
|
+
[_ in Key]: TPick<Type, [Key]>;
|
|
7
7
|
};
|
|
8
|
-
type TFromPropertyKeys<
|
|
9
|
-
type TFromMappedKey<
|
|
10
|
-
export type TPickFromMappedKey<
|
|
11
|
-
export declare function PickFromMappedKey<
|
|
8
|
+
type TFromPropertyKeys<Type extends TSchema, PropertyKeys extends PropertyKey[], Result extends TProperties = {}> = (PropertyKeys extends [infer LeftKey extends PropertyKey, ...infer RightKeys extends PropertyKey[]] ? TFromPropertyKeys<Type, RightKeys, Result & TFromPropertyKey<Type, LeftKey>> : Result);
|
|
9
|
+
type TFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey> = (TFromPropertyKeys<Type, MappedKey['keys']>);
|
|
10
|
+
export type TPickFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey, Properties extends TProperties = TFromMappedKey<Type, MappedKey>> = (TMappedResult<Properties>);
|
|
11
|
+
export declare function PickFromMappedKey<Type extends TSchema, MappedKey extends TMappedKey, Properties extends TProperties = TFromMappedKey<Type, MappedKey>>(type: Type, mappedKey: MappedKey, options?: SchemaOptions): TMappedResult<Properties>;
|
|
12
12
|
export {};
|
|
@@ -6,23 +6,23 @@ const index_1 = require("../mapped/index");
|
|
|
6
6
|
const pick_1 = require("./pick");
|
|
7
7
|
const value_1 = require("../clone/value");
|
|
8
8
|
// prettier-ignore
|
|
9
|
-
function FromPropertyKey(
|
|
9
|
+
function FromPropertyKey(type, key, options) {
|
|
10
10
|
return {
|
|
11
|
-
[
|
|
11
|
+
[key]: (0, pick_1.Pick)(type, [key], (0, value_1.Clone)(options))
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
function FromPropertyKeys(
|
|
16
|
-
return
|
|
17
|
-
return { ...
|
|
15
|
+
function FromPropertyKeys(type, propertyKeys, options) {
|
|
16
|
+
return propertyKeys.reduce((result, leftKey) => {
|
|
17
|
+
return { ...result, ...FromPropertyKey(type, leftKey, options) };
|
|
18
18
|
}, {});
|
|
19
19
|
}
|
|
20
20
|
// prettier-ignore
|
|
21
|
-
function FromMappedKey(
|
|
22
|
-
return FromPropertyKeys(
|
|
21
|
+
function FromMappedKey(type, mappedKey, options) {
|
|
22
|
+
return FromPropertyKeys(type, mappedKey.keys, options);
|
|
23
23
|
}
|
|
24
24
|
// prettier-ignore
|
|
25
|
-
function PickFromMappedKey(
|
|
26
|
-
const
|
|
27
|
-
return (0, index_1.MappedResult)(
|
|
25
|
+
function PickFromMappedKey(type, mappedKey, options) {
|
|
26
|
+
const properties = FromMappedKey(type, mappedKey, options);
|
|
27
|
+
return (0, index_1.MappedResult)(properties);
|
|
28
28
|
}
|
|
@@ -3,10 +3,10 @@ import type { Ensure, Evaluate } from '../helpers/index';
|
|
|
3
3
|
import type { TProperties } from '../object/index';
|
|
4
4
|
import { type TMappedResult } from '../mapped/index';
|
|
5
5
|
import { type TPick } from './pick';
|
|
6
|
-
type TFromProperties<
|
|
7
|
-
[K2 in keyof
|
|
6
|
+
type TFromProperties<Properties extends TProperties, PropertyKeys extends PropertyKey[]> = ({
|
|
7
|
+
[K2 in keyof Properties]: TPick<Properties[K2], PropertyKeys>;
|
|
8
8
|
});
|
|
9
|
-
type TFromMappedResult<
|
|
10
|
-
export type TPickFromMappedResult<
|
|
11
|
-
export declare function PickFromMappedResult<
|
|
9
|
+
type TFromMappedResult<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[]> = (Evaluate<TFromProperties<MappedResult['properties'], PropertyKeys>>);
|
|
10
|
+
export type TPickFromMappedResult<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[], Properties extends TProperties = TFromMappedResult<MappedResult, PropertyKeys>> = (Ensure<TMappedResult<Properties>>);
|
|
11
|
+
export declare function PickFromMappedResult<MappedResult extends TMappedResult, PropertyKeys extends PropertyKey[], Properties extends TProperties = TFromMappedResult<MappedResult, PropertyKeys>>(mappedResult: MappedResult, propertyKeys: [...PropertyKeys], options?: SchemaOptions): TMappedResult<Properties>;
|
|
12
12
|
export {};
|
|
@@ -6,18 +6,18 @@ const index_1 = require("../mapped/index");
|
|
|
6
6
|
const pick_1 = require("./pick");
|
|
7
7
|
const value_1 = require("../clone/value");
|
|
8
8
|
// prettier-ignore
|
|
9
|
-
function FromProperties(
|
|
10
|
-
const
|
|
11
|
-
for (const K2 of globalThis.Object.getOwnPropertyNames(
|
|
12
|
-
|
|
13
|
-
return
|
|
9
|
+
function FromProperties(properties, propertyKeys, options) {
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
12
|
+
result[K2] = (0, pick_1.Pick)(properties[K2], propertyKeys, (0, value_1.Clone)(options));
|
|
13
|
+
return result;
|
|
14
14
|
}
|
|
15
15
|
// prettier-ignore
|
|
16
|
-
function FromMappedResult(
|
|
17
|
-
return FromProperties(
|
|
16
|
+
function FromMappedResult(mappedResult, propertyKeys, options) {
|
|
17
|
+
return FromProperties(mappedResult.properties, propertyKeys, options);
|
|
18
18
|
}
|
|
19
19
|
// prettier-ignore
|
|
20
|
-
function PickFromMappedResult(
|
|
21
|
-
const
|
|
22
|
-
return (0, index_1.MappedResult)(
|
|
20
|
+
function PickFromMappedResult(mappedResult, propertyKeys, options) {
|
|
21
|
+
const properties = FromMappedResult(mappedResult, propertyKeys, options);
|
|
22
|
+
return (0, index_1.MappedResult)(properties);
|
|
23
23
|
}
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { TupleToUnion, Evaluate, Ensure } from '../helpers/index';
|
|
3
3
|
import { type TRecursive } from '../recursive/index';
|
|
4
|
+
import { type TComputed } from '../computed/index';
|
|
4
5
|
import { type TIntersect } from '../intersect/index';
|
|
5
|
-
import { type
|
|
6
|
+
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
6
7
|
import { type TObject, type TProperties } from '../object/index';
|
|
7
|
-
import
|
|
8
|
+
import { type TUnion } from '../union/index';
|
|
9
|
+
import { type TMappedKey, type TMappedResult } from '../mapped/index';
|
|
10
|
+
import { type TRef } from '../ref/index';
|
|
8
11
|
import { type TIndexPropertyKeys } from '../indexed/index';
|
|
9
12
|
import { type TPickFromMappedKey } from './pick-from-mapped-key';
|
|
10
13
|
import { type TPickFromMappedResult } from './pick-from-mapped-result';
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
type TFromIntersect<Types extends TSchema[], PropertyKeys extends PropertyKey[], Result extends TSchema[] = []> = Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, PropertyKeys, [...Result, TPick<L, PropertyKeys>]> : Result;
|
|
15
|
+
type TFromUnion<Types extends TSchema[], PropertyKeys extends PropertyKey[], Result extends TSchema[] = []> = Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, PropertyKeys, [...Result, TPick<L, PropertyKeys>]> : Result;
|
|
16
|
+
type TFromProperties<Properties extends TProperties, PropertyKeys extends PropertyKey[], UnionKeys extends PropertyKey = TupleToUnion<PropertyKeys>> = (Evaluate<Pick<Properties, UnionKeys & keyof Properties>>);
|
|
17
|
+
type TFromObject<Type extends TObject, Key extends PropertyKey[], Properties extends TProperties = Type['properties']> = Ensure<TObject<(TFromProperties<Properties, Key>)>>;
|
|
18
|
+
type TUnionFromPropertyKeys<PropertyKeys extends PropertyKey[], Result extends TLiteral[] = []> = (PropertyKeys extends [infer Key extends PropertyKey, ...infer Rest extends PropertyKey[]] ? Key extends TLiteralValue ? TUnionFromPropertyKeys<Rest, [...Result, TLiteral<Key>]> : TUnionFromPropertyKeys<Rest, [...Result]> : TUnion<Result>);
|
|
19
|
+
export type TPickResolve<Properties extends TProperties, PropertyKeys extends PropertyKey[]> = (Properties extends TRecursive<infer Types extends TSchema> ? TRecursive<TPickResolve<Types, PropertyKeys>> : Properties extends TIntersect<infer Types extends TSchema[]> ? TIntersect<TFromIntersect<Types, PropertyKeys>> : Properties extends TUnion<infer Types extends TSchema[]> ? TUnion<TFromUnion<Types, PropertyKeys>> : Properties extends TObject<infer Types extends TProperties> ? TFromObject<TObject<Types>, PropertyKeys> : TObject<{}>);
|
|
20
|
+
type TResolvePropertyKeys<Key extends TSchema | PropertyKey[]> = Key extends TSchema ? TIndexPropertyKeys<Key> : Key;
|
|
21
|
+
type TResolveTypeKey<Key extends TSchema | PropertyKey[]> = Key extends PropertyKey[] ? TUnionFromPropertyKeys<Key> : Key;
|
|
22
|
+
export type TPick<Type extends TSchema, Key extends TSchema | PropertyKey[], IsTypeRef extends boolean = Type extends TRef ? true : false, IsKeyRef extends boolean = Key extends TRef ? true : false> = (Type extends TMappedResult ? TPickFromMappedResult<Type, TResolvePropertyKeys<Key>> : Key extends TMappedKey ? TPickFromMappedKey<Type, Key> : [
|
|
23
|
+
IsTypeRef,
|
|
24
|
+
IsKeyRef
|
|
25
|
+
] extends [true, true] ? TComputed<'Pick', [Type, TResolveTypeKey<Key>]> : [
|
|
26
|
+
IsTypeRef,
|
|
27
|
+
IsKeyRef
|
|
28
|
+
] extends [false, true] ? TComputed<'Pick', [Type, TResolveTypeKey<Key>]> : [
|
|
29
|
+
IsTypeRef,
|
|
30
|
+
IsKeyRef
|
|
31
|
+
] extends [true, false] ? TComputed<'Pick', [Type, TResolveTypeKey<Key>]> : TPickResolve<Type, TResolvePropertyKeys<Key>>);
|
|
22
32
|
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
23
|
-
export declare function Pick<
|
|
33
|
+
export declare function Pick<Type extends TSchema, Key extends PropertyKey[]>(type: Type, key: readonly [...Key], options?: SchemaOptions): TPick<Type, Key>;
|
|
24
34
|
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
25
|
-
export declare function Pick<
|
|
35
|
+
export declare function Pick<Type extends TSchema, Key extends TSchema>(type: Type, key: Key, options?: SchemaOptions): TPick<Type, Key>;
|
|
26
36
|
export {};
|
|
@@ -4,56 +4,67 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Pick = Pick;
|
|
5
5
|
const type_1 = require("../create/type");
|
|
6
6
|
const discard_1 = require("../discard/discard");
|
|
7
|
-
const index_1 = require("../
|
|
8
|
-
const index_2 = require("../
|
|
9
|
-
const index_3 = require("../
|
|
10
|
-
const index_4 = require("../
|
|
11
|
-
const
|
|
12
|
-
const
|
|
7
|
+
const index_1 = require("../computed/index");
|
|
8
|
+
const index_2 = require("../intersect/index");
|
|
9
|
+
const index_3 = require("../literal/index");
|
|
10
|
+
const index_4 = require("../object/index");
|
|
11
|
+
const index_5 = require("../union/index");
|
|
12
|
+
const index_6 = require("../indexed/index");
|
|
13
13
|
const symbols_1 = require("../symbols/symbols");
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
|
-
//
|
|
15
|
+
// Guards
|
|
16
16
|
// ------------------------------------------------------------------
|
|
17
17
|
const kind_1 = require("../guard/kind");
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const guard_1 = require("src/value/guard");
|
|
19
|
+
// ------------------------------------------------------------------
|
|
20
|
+
// Infrastructure
|
|
21
|
+
// ------------------------------------------------------------------
|
|
22
|
+
const pick_from_mapped_key_1 = require("./pick-from-mapped-key");
|
|
23
|
+
const pick_from_mapped_result_1 = require("./pick-from-mapped-result");
|
|
24
|
+
function FromIntersect(types, propertyKeys) {
|
|
25
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
20
26
|
}
|
|
21
27
|
// prettier-ignore
|
|
22
|
-
function FromUnion(
|
|
23
|
-
return
|
|
28
|
+
function FromUnion(types, propertyKeys) {
|
|
29
|
+
return types.map((type) => PickResolve(type, propertyKeys));
|
|
24
30
|
}
|
|
25
31
|
// prettier-ignore
|
|
26
|
-
function FromProperties(
|
|
27
|
-
const
|
|
28
|
-
for (const K2 of
|
|
29
|
-
if (K2 in
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
+
function FromProperties(properties, propertyKeys) {
|
|
33
|
+
const result = {};
|
|
34
|
+
for (const K2 of propertyKeys)
|
|
35
|
+
if (K2 in properties)
|
|
36
|
+
result[K2] = properties[K2];
|
|
37
|
+
return result;
|
|
32
38
|
}
|
|
33
39
|
// prettier-ignore
|
|
34
40
|
function FromObject(T, K) {
|
|
35
41
|
const options = (0, discard_1.Discard)(T, [symbols_1.TransformKind, '$id', 'required', 'properties']);
|
|
36
42
|
const properties = FromProperties(T['properties'], K);
|
|
37
|
-
return (0,
|
|
43
|
+
return (0, index_4.Object)(properties, options);
|
|
38
44
|
}
|
|
39
|
-
// ------------------------------------------------------------------
|
|
40
|
-
// PickResolve
|
|
41
|
-
// ------------------------------------------------------------------
|
|
42
45
|
// prettier-ignore
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(0, kind_1.IsObject)(T) ? FromObject(T, K) :
|
|
47
|
-
(0, index_3.Object)({}));
|
|
46
|
+
function UnionFromPropertyKeys(propertyKeys) {
|
|
47
|
+
const result = propertyKeys.reduce((result, key) => (0, kind_1.IsLiteralValue)(key) ? [...result, (0, index_3.Literal)(key)] : result, []);
|
|
48
|
+
return (0, index_5.Union)(result);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
// prettier-ignore
|
|
51
|
+
function PickResolve(properties, propertyKeys) {
|
|
52
|
+
return ((0, kind_1.IsIntersect)(properties) ? (0, index_2.Intersect)(FromIntersect(properties.allOf, propertyKeys)) :
|
|
53
|
+
(0, kind_1.IsUnion)(properties) ? (0, index_5.Union)(FromUnion(properties.anyOf, propertyKeys)) :
|
|
54
|
+
(0, kind_1.IsObject)(properties) ? FromObject(properties, propertyKeys) :
|
|
55
|
+
(0, index_4.Object)({}));
|
|
56
|
+
}
|
|
57
|
+
/** `[Json]` Constructs a type whose keys are picked from the given type */
|
|
58
|
+
// prettier-ignore
|
|
59
|
+
function Pick(type, key, options) {
|
|
60
|
+
const typeKey = (0, guard_1.IsArray)(key) ? UnionFromPropertyKeys(key) : key;
|
|
61
|
+
const propertyKeys = (0, kind_1.IsSchema)(key) ? (0, index_6.IndexPropertyKeys)(key) : key;
|
|
62
|
+
const isTypeRef = (0, kind_1.IsRef)(type);
|
|
63
|
+
const isKeyRef = (0, kind_1.IsRef)(key);
|
|
64
|
+
return ((0, kind_1.IsMappedResult)(type) ? (0, pick_from_mapped_result_1.PickFromMappedResult)(type, propertyKeys, options) :
|
|
65
|
+
(0, kind_1.IsMappedKey)(key) ? (0, pick_from_mapped_key_1.PickFromMappedKey)(type, key, options) :
|
|
66
|
+
(isTypeRef && isKeyRef) ? (0, index_1.Computed)('Pick', [type, typeKey], options) :
|
|
67
|
+
(!isTypeRef && isKeyRef) ? (0, index_1.Computed)('Pick', [type, typeKey], options) :
|
|
68
|
+
(isTypeRef && !isKeyRef) ? (0, index_1.Computed)('Pick', [type, typeKey], options) :
|
|
69
|
+
(0, type_1.CreateType)({ ...PickResolve(type, propertyKeys), ...options }));
|
|
59
70
|
}
|
|
@@ -2,6 +2,7 @@ import type { TSchema } from '../schema/index';
|
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import type { Evaluate, Ensure, Assert } from '../helpers/index';
|
|
4
4
|
import { type TAny } from '../any/index';
|
|
5
|
+
import { type TComputed } from '../computed/index';
|
|
5
6
|
import { type TObject, type TProperties, type TAdditionalProperties, type ObjectOptions } from '../object/index';
|
|
6
7
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
7
8
|
import { type TNever } from '../never/index';
|
|
@@ -11,6 +12,7 @@ import { type TString } from '../string/index';
|
|
|
11
12
|
import { type TInteger } from '../integer/index';
|
|
12
13
|
import { type TNumber } from '../number/index';
|
|
13
14
|
import { type TEnum } from '../enum/index';
|
|
15
|
+
import { type TRef } from '../ref/index';
|
|
14
16
|
import { TIsTemplateLiteralFinite, type TTemplateLiteral } from '../template-literal/index';
|
|
15
17
|
import { Kind } from '../symbols/index';
|
|
16
18
|
type TFromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
|
|
@@ -50,7 +52,7 @@ export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchem
|
|
|
50
52
|
};
|
|
51
53
|
additionalProperties: TAdditionalProperties;
|
|
52
54
|
}
|
|
53
|
-
export type TRecordOrObject<
|
|
55
|
+
export type TRecordOrObject<Key extends TSchema, Type extends TSchema> = Type extends TRef ? TComputed<'Record', [Key, Type]> : Key extends TRef ? TComputed<'Record', [Key, Type]> : Key extends TTemplateLiteral ? TFromTemplateLiteralKey<Key, Type> : Key extends TEnum<infer S> ? TFromEnumKey<S, Type> : Key extends TUnion<infer S> ? TFromUnionKey<S, Type> : Key extends TLiteral<infer S> ? TFromLiteralKey<S, Type> : Key extends TInteger ? TFromIntegerKey<Key, Type> : Key extends TNumber ? TFromNumberKey<Key, Type> : Key extends TRegExp ? TFromRegExpKey<Key, Type> : Key extends TString ? TFromStringKey<Key, Type> : Key extends TAny ? TFromAnyKey<Key, Type> : Key extends TNever ? TFromNeverKey<Key, Type> : TNever;
|
|
54
56
|
/** `[Json]` Creates a Record type */
|
|
55
|
-
export declare function Record<
|
|
57
|
+
export declare function Record<Key extends TSchema, Type extends TSchema>(key: Key, type: Type, options?: ObjectOptions): TRecordOrObject<Key, Type>;
|
|
56
58
|
export {};
|