@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.
- 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
|
@@ -5,80 +5,93 @@ exports.IndexFromPropertyKey = IndexFromPropertyKey;
|
|
|
5
5
|
exports.IndexFromPropertyKeys = IndexFromPropertyKeys;
|
|
6
6
|
exports.Index = Index;
|
|
7
7
|
const type_1 = require("../create/type");
|
|
8
|
-
const index_1 = require("../
|
|
9
|
-
const index_2 = require("../
|
|
10
|
-
const index_3 = require("../
|
|
8
|
+
const index_1 = require("../computed/index");
|
|
9
|
+
const index_2 = require("../literal/index");
|
|
10
|
+
const index_3 = require("../never/index");
|
|
11
|
+
const index_4 = require("../intersect/index");
|
|
12
|
+
const index_5 = require("../union/index");
|
|
13
|
+
// ------------------------------------------------------------------
|
|
14
|
+
// Infrastructure
|
|
15
|
+
// ------------------------------------------------------------------
|
|
11
16
|
const indexed_property_keys_1 = require("./indexed-property-keys");
|
|
12
17
|
const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
|
|
13
18
|
const indexed_from_mapped_result_1 = require("./indexed-from-mapped-result");
|
|
14
19
|
// ------------------------------------------------------------------
|
|
15
|
-
//
|
|
20
|
+
// KindGuard
|
|
16
21
|
// ------------------------------------------------------------------
|
|
17
22
|
const kind_1 = require("../guard/kind");
|
|
23
|
+
const value_1 = require("../guard/value");
|
|
18
24
|
// prettier-ignore
|
|
19
|
-
function FromRest(
|
|
20
|
-
return
|
|
25
|
+
function FromRest(types, key) {
|
|
26
|
+
return types.map(left => IndexFromPropertyKey(left, key));
|
|
21
27
|
}
|
|
22
28
|
// prettier-ignore
|
|
23
|
-
function FromIntersectRest(
|
|
24
|
-
return
|
|
29
|
+
function FromIntersectRest(types) {
|
|
30
|
+
return types.filter(left => !(0, kind_1.IsNever)(left));
|
|
25
31
|
}
|
|
26
32
|
// prettier-ignore
|
|
27
|
-
function FromIntersect(
|
|
28
|
-
return ((0,
|
|
33
|
+
function FromIntersect(types, key) {
|
|
34
|
+
return ((0, index_4.IntersectEvaluated)(FromIntersectRest(FromRest(types, key))));
|
|
29
35
|
}
|
|
30
36
|
// prettier-ignore
|
|
31
|
-
function FromUnionRest(
|
|
32
|
-
return (
|
|
37
|
+
function FromUnionRest(types) {
|
|
38
|
+
return (types.some(L => (0, kind_1.IsNever)(L))
|
|
33
39
|
? []
|
|
34
|
-
:
|
|
40
|
+
: types);
|
|
35
41
|
}
|
|
36
42
|
// prettier-ignore
|
|
37
|
-
function FromUnion(
|
|
38
|
-
return ((0,
|
|
43
|
+
function FromUnion(types, key) {
|
|
44
|
+
return ((0, index_5.UnionEvaluated)(FromUnionRest(FromRest(types, key))));
|
|
39
45
|
}
|
|
40
46
|
// prettier-ignore
|
|
41
|
-
function FromTuple(
|
|
42
|
-
return (
|
|
43
|
-
|
|
44
|
-
(0,
|
|
47
|
+
function FromTuple(types, key) {
|
|
48
|
+
return (key === '[number]' ? (0, index_5.UnionEvaluated)(types) :
|
|
49
|
+
key in types ? types[key] :
|
|
50
|
+
(0, index_3.Never)());
|
|
45
51
|
}
|
|
46
52
|
// prettier-ignore
|
|
47
|
-
function FromArray(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
: (0, index_1.Never)());
|
|
53
|
+
function FromArray(type, key) {
|
|
54
|
+
// ... ?
|
|
55
|
+
return (key === '[number]' ? type : (0, index_3.Never)());
|
|
51
56
|
}
|
|
52
57
|
// prettier-ignore
|
|
53
|
-
function FromProperty(
|
|
54
|
-
return (
|
|
58
|
+
function FromProperty(properties, key) {
|
|
59
|
+
return (key in properties ? properties[key] : (0, index_3.Never)());
|
|
55
60
|
}
|
|
56
61
|
// prettier-ignore
|
|
57
|
-
function IndexFromPropertyKey(
|
|
58
|
-
return ((0, kind_1.IsIntersect)(
|
|
59
|
-
(0, kind_1.IsUnion)(
|
|
60
|
-
(0, kind_1.IsTuple)(
|
|
61
|
-
(0, kind_1.IsArray)(
|
|
62
|
-
(0, kind_1.IsObject)(
|
|
63
|
-
(0,
|
|
62
|
+
function IndexFromPropertyKey(type, key) {
|
|
63
|
+
return ((0, kind_1.IsIntersect)(type) ? FromIntersect(type.allOf, key) :
|
|
64
|
+
(0, kind_1.IsUnion)(type) ? FromUnion(type.anyOf, key) :
|
|
65
|
+
(0, kind_1.IsTuple)(type) ? FromTuple(type.items ?? [], key) :
|
|
66
|
+
(0, kind_1.IsArray)(type) ? FromArray(type.items, key) :
|
|
67
|
+
(0, kind_1.IsObject)(type) ? FromProperty(type.properties, key) :
|
|
68
|
+
(0, index_3.Never)());
|
|
64
69
|
}
|
|
65
70
|
// prettier-ignore
|
|
66
|
-
function IndexFromPropertyKeys(
|
|
67
|
-
return
|
|
71
|
+
function IndexFromPropertyKeys(type, propertyKeys) {
|
|
72
|
+
return propertyKeys.map(left => IndexFromPropertyKey(type, left));
|
|
68
73
|
}
|
|
69
74
|
// prettier-ignore
|
|
70
|
-
function
|
|
71
|
-
|
|
75
|
+
function FromType(type, propertyKeys) {
|
|
76
|
+
const result = IndexFromPropertyKeys(type, propertyKeys);
|
|
77
|
+
return (0, index_5.UnionEvaluated)(result);
|
|
78
|
+
}
|
|
79
|
+
// prettier-ignore
|
|
80
|
+
function UnionFromPropertyKeys(propertyKeys) {
|
|
81
|
+
const result = propertyKeys.reduce((result, key) => (0, kind_1.IsLiteralValue)(key) ? [...result, (0, index_2.Literal)(key)] : result, []);
|
|
82
|
+
return (0, index_5.UnionEvaluated)(result);
|
|
72
83
|
}
|
|
73
84
|
/** `[Json]` Returns an Indexed property type for the given keys */
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
// prettier-ignore
|
|
86
|
+
function Index(type, key, options) {
|
|
87
|
+
const typeKey = (0, value_1.IsArray)(key) ? UnionFromPropertyKeys(key) : key;
|
|
88
|
+
const propertyKeys = (0, kind_1.IsSchema)(key) ? (0, indexed_property_keys_1.IndexPropertyKeys)(key) : key;
|
|
89
|
+
const isTypeRef = (0, kind_1.IsRef)(type);
|
|
90
|
+
const isKeyRef = (0, kind_1.IsRef)(key);
|
|
91
|
+
return ((0, kind_1.IsMappedResult)(key) ? (0, indexed_from_mapped_result_1.IndexFromMappedResult)(type, key, options) :
|
|
92
|
+
(0, kind_1.IsMappedKey)(key) ? (0, indexed_from_mapped_key_1.IndexFromMappedKey)(type, key, options) :
|
|
93
|
+
(isTypeRef && isKeyRef) ? (0, index_1.Computed)('Index', [type, typeKey], options) :
|
|
94
|
+
(!isTypeRef && isKeyRef) ? (0, index_1.Computed)('Index', [type, typeKey], options) :
|
|
95
|
+
(isTypeRef && !isKeyRef) ? (0, index_1.Computed)('Index', [type, typeKey], options) :
|
|
96
|
+
(0, type_1.CreateType)(FromType(type, propertyKeys), options));
|
|
84
97
|
}
|
|
@@ -3,11 +3,11 @@ import { type TNever } from '../never/index';
|
|
|
3
3
|
import { type TOptional } from '../optional/index';
|
|
4
4
|
import type { TReadonly } from '../readonly/index';
|
|
5
5
|
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
6
|
-
type TIsIntersectOptional<
|
|
7
|
-
type TRemoveOptionalFromType<
|
|
8
|
-
type TRemoveOptionalFromRest<
|
|
9
|
-
type TResolveIntersect<
|
|
10
|
-
export type TIntersectEvaluated<
|
|
6
|
+
type TIsIntersectOptional<Types extends TSchema[]> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TOptional<TSchema> ? TIsIntersectOptional<Right> : false : true);
|
|
7
|
+
type TRemoveOptionalFromType<Type extends TSchema> = (Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TRemoveOptionalFromType<Type>> : Type extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromType<Type> : Type);
|
|
8
|
+
type TRemoveOptionalFromRest<Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TOptional<infer Type extends TSchema> ? TRemoveOptionalFromRest<Right, [...Result, TRemoveOptionalFromType<Type>]> : TRemoveOptionalFromRest<Right, [...Result, Left]> : Result);
|
|
9
|
+
type TResolveIntersect<Types extends TSchema[]> = (TIsIntersectOptional<Types> extends true ? TOptional<TIntersect<TRemoveOptionalFromRest<Types>>> : TIntersect<TRemoveOptionalFromRest<Types>>);
|
|
10
|
+
export type TIntersectEvaluated<Types extends TSchema[]> = (Types extends [TSchema] ? Types[0] : Types extends [] ? TNever : TResolveIntersect<Types>);
|
|
11
11
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
12
|
-
export declare function IntersectEvaluated<
|
|
12
|
+
export declare function IntersectEvaluated<Types extends TSchema[], Result extends TSchema = TIntersectEvaluated<Types>>(types: [...Types], options?: IntersectOptions): Result;
|
|
13
13
|
export {};
|
|
@@ -13,30 +13,30 @@ const intersect_create_1 = require("./intersect-create");
|
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
const kind_1 = require("../guard/kind");
|
|
15
15
|
// prettier-ignore
|
|
16
|
-
function IsIntersectOptional(
|
|
17
|
-
return
|
|
16
|
+
function IsIntersectOptional(types) {
|
|
17
|
+
return types.every(left => (0, kind_1.IsOptional)(left));
|
|
18
18
|
}
|
|
19
19
|
// prettier-ignore
|
|
20
|
-
function RemoveOptionalFromType(
|
|
21
|
-
return ((0, index_2.Discard)(
|
|
20
|
+
function RemoveOptionalFromType(type) {
|
|
21
|
+
return ((0, index_2.Discard)(type, [index_1.OptionalKind]));
|
|
22
22
|
}
|
|
23
23
|
// prettier-ignore
|
|
24
|
-
function RemoveOptionalFromRest(
|
|
25
|
-
return
|
|
24
|
+
function RemoveOptionalFromRest(types) {
|
|
25
|
+
return types.map(left => (0, kind_1.IsOptional)(left) ? RemoveOptionalFromType(left) : left);
|
|
26
26
|
}
|
|
27
27
|
// prettier-ignore
|
|
28
|
-
function ResolveIntersect(
|
|
29
|
-
return (IsIntersectOptional(
|
|
30
|
-
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(
|
|
31
|
-
: (0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(
|
|
28
|
+
function ResolveIntersect(types, options) {
|
|
29
|
+
return (IsIntersectOptional(types)
|
|
30
|
+
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(types), options))
|
|
31
|
+
: (0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(types), options));
|
|
32
32
|
}
|
|
33
33
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
34
|
-
function IntersectEvaluated(
|
|
35
|
-
if (
|
|
34
|
+
function IntersectEvaluated(types, options = {}) {
|
|
35
|
+
if (types.length === 1)
|
|
36
|
+
return (0, type_1.CreateType)(types[0], options);
|
|
37
|
+
if (types.length === 0)
|
|
36
38
|
return (0, index_3.Never)(options);
|
|
37
|
-
if (
|
|
38
|
-
return (0, type_1.CreateType)(T[0], options);
|
|
39
|
-
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
39
|
+
if (types.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
40
40
|
throw new Error('Cannot intersect transform types');
|
|
41
|
-
return ResolveIntersect(
|
|
41
|
+
return ResolveIntersect(types, options);
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
2
|
import { type TNever } from '../never/index';
|
|
3
3
|
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
4
|
-
export type Intersect<
|
|
4
|
+
export type Intersect<Types extends TSchema[]> = (Types extends [TSchema] ? Types[0] : Types extends [] ? TNever : TIntersect<Types>);
|
|
5
5
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
6
|
-
export declare function Intersect<
|
|
6
|
+
export declare function Intersect<Types extends TSchema[]>(types: [...Types], options?: IntersectOptions): Intersect<Types>;
|
|
@@ -10,12 +10,12 @@ const intersect_create_1 = require("./intersect-create");
|
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
11
|
const kind_1 = require("../guard/kind");
|
|
12
12
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
13
|
-
function Intersect(
|
|
14
|
-
if (
|
|
13
|
+
function Intersect(types, options) {
|
|
14
|
+
if (types.length === 1)
|
|
15
|
+
return (0, type_1.CreateType)(types[0], options);
|
|
16
|
+
if (types.length === 0)
|
|
15
17
|
return (0, index_1.Never)(options);
|
|
16
|
-
if (
|
|
17
|
-
return (0, type_1.CreateType)(T[0], options);
|
|
18
|
-
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
18
|
+
if (types.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
19
19
|
throw new Error('Cannot intersect transform types');
|
|
20
|
-
return (0, intersect_create_1.IntersectCreate)(
|
|
20
|
+
return (0, intersect_create_1.IntersectCreate)(types, options);
|
|
21
21
|
}
|
|
@@ -2,11 +2,11 @@ import type { SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Ensure, Evaluate } from '../helpers/index';
|
|
3
3
|
import type { TProperties } from '../object/index';
|
|
4
4
|
import { type TMappedResult } from '../mapped/index';
|
|
5
|
-
import { type
|
|
6
|
-
type TFromProperties<
|
|
7
|
-
[K2 in keyof
|
|
5
|
+
import { type TKeyOfFromType } from './keyof';
|
|
6
|
+
type TFromProperties<Properties extends TProperties> = ({
|
|
7
|
+
[K2 in keyof Properties]: TKeyOfFromType<Properties[K2]>;
|
|
8
8
|
});
|
|
9
|
-
type TFromMappedResult<
|
|
10
|
-
export type TKeyOfFromMappedResult<
|
|
11
|
-
export declare function KeyOfFromMappedResult<
|
|
9
|
+
type TFromMappedResult<MappedResult extends TMappedResult> = (Evaluate<TFromProperties<MappedResult['properties']>>);
|
|
10
|
+
export type TKeyOfFromMappedResult<MappedResult extends TMappedResult, Properties extends TProperties = TFromMappedResult<MappedResult>> = (Ensure<TMappedResult<Properties>>);
|
|
11
|
+
export declare function KeyOfFromMappedResult<MappedResult extends TMappedResult, Properties extends TProperties = TFromMappedResult<MappedResult>>(mappedResult: MappedResult, options?: SchemaOptions): TMappedResult<Properties>;
|
|
12
12
|
export {};
|
|
@@ -6,18 +6,18 @@ const index_1 = require("../mapped/index");
|
|
|
6
6
|
const keyof_1 = require("./keyof");
|
|
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, options) {
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
|
|
12
|
+
result[K2] = (0, keyof_1.KeyOf)(properties[K2], (0, value_1.Clone)(options));
|
|
13
|
+
return result;
|
|
14
14
|
}
|
|
15
15
|
// prettier-ignore
|
|
16
|
-
function FromMappedResult(
|
|
17
|
-
return FromProperties(
|
|
16
|
+
function FromMappedResult(mappedResult, options) {
|
|
17
|
+
return FromProperties(mappedResult.properties, options);
|
|
18
18
|
}
|
|
19
19
|
// prettier-ignore
|
|
20
|
-
function KeyOfFromMappedResult(
|
|
21
|
-
const
|
|
22
|
-
return (0, index_1.MappedResult)(
|
|
20
|
+
function KeyOfFromMappedResult(mappedResult, options) {
|
|
21
|
+
const properties = FromMappedResult(mappedResult, options);
|
|
22
|
+
return (0, index_1.MappedResult)(properties);
|
|
23
23
|
}
|
|
@@ -7,18 +7,18 @@ import type { TTuple } from '../tuple/index';
|
|
|
7
7
|
import type { TArray } from '../array/index';
|
|
8
8
|
import type { TObject, TProperties } from '../object/index';
|
|
9
9
|
import { type TSetUnionMany, type TSetIntersectMany } from '../sets/index';
|
|
10
|
-
type TFromRest<
|
|
11
|
-
type TFromIntersect<
|
|
12
|
-
type TFromUnion<
|
|
13
|
-
type TFromTuple<
|
|
10
|
+
type TFromRest<Types extends TSchema[], Result extends PropertyKey[][] = []> = (Types extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Result, TKeyOfPropertyKeys<L>]> : Result);
|
|
11
|
+
type TFromIntersect<Types extends TSchema[], PropertyKeysArray extends PropertyKey[][] = TFromRest<Types>, PropertyKeys extends PropertyKey[] = TSetUnionMany<PropertyKeysArray>> = PropertyKeys;
|
|
12
|
+
type TFromUnion<Types extends TSchema[], PropertyKeysArray extends PropertyKey[][] = TFromRest<Types>, PropertyKeys extends PropertyKey[] = TSetIntersectMany<PropertyKeysArray>> = PropertyKeys;
|
|
13
|
+
type TFromTuple<Types extends TSchema[], Indexer extends string = ZeroString, Acc extends PropertyKey[] = []> = Types extends [infer _ extends TSchema, ...infer R extends TSchema[]] ? TFromTuple<R, TIncrement<Indexer>, [...Acc, Indexer]> : Acc;
|
|
14
14
|
type TFromArray<_ extends TSchema> = ([
|
|
15
15
|
'[number]'
|
|
16
16
|
]);
|
|
17
|
-
type TFromProperties<
|
|
18
|
-
export type TKeyOfPropertyKeys<
|
|
17
|
+
type TFromProperties<Properties extends TProperties> = (UnionToTuple<keyof Properties>);
|
|
18
|
+
export type TKeyOfPropertyKeys<Type extends TSchema> = (Type extends TRecursive<infer Type extends TSchema> ? TKeyOfPropertyKeys<Type> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<Types> : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<Types> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<Types> : Type extends TArray<infer Type extends TSchema> ? TFromArray<Type> : Type extends TObject<infer Properties extends TProperties> ? TFromProperties<Properties> : [
|
|
19
19
|
]);
|
|
20
20
|
/** Returns a tuple of PropertyKeys derived from the given TSchema. */
|
|
21
|
-
export declare function KeyOfPropertyKeys<
|
|
21
|
+
export declare function KeyOfPropertyKeys<Type extends TSchema>(type: Type): TKeyOfPropertyKeys<Type>;
|
|
22
22
|
/** Returns a regular expression pattern derived from the given TSchema */
|
|
23
23
|
export declare function KeyOfPattern(schema: TSchema): string;
|
|
24
24
|
export {};
|
|
@@ -9,27 +9,27 @@ const index_1 = require("../sets/index");
|
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
const kind_1 = require("../guard/kind");
|
|
11
11
|
// prettier-ignore
|
|
12
|
-
function FromRest(
|
|
13
|
-
const
|
|
14
|
-
for (const L of
|
|
15
|
-
|
|
16
|
-
return
|
|
12
|
+
function FromRest(types) {
|
|
13
|
+
const result = [];
|
|
14
|
+
for (const L of types)
|
|
15
|
+
result.push(KeyOfPropertyKeys(L));
|
|
16
|
+
return result;
|
|
17
17
|
}
|
|
18
18
|
// prettier-ignore
|
|
19
|
-
function FromIntersect(
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
return
|
|
19
|
+
function FromIntersect(types) {
|
|
20
|
+
const propertyKeysArray = FromRest(types);
|
|
21
|
+
const propertyKeys = (0, index_1.SetUnionMany)(propertyKeysArray);
|
|
22
|
+
return propertyKeys;
|
|
23
23
|
}
|
|
24
24
|
// prettier-ignore
|
|
25
|
-
function FromUnion(
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
return
|
|
25
|
+
function FromUnion(types) {
|
|
26
|
+
const propertyKeysArray = FromRest(types);
|
|
27
|
+
const propertyKeys = (0, index_1.SetIntersectMany)(propertyKeysArray);
|
|
28
|
+
return propertyKeys;
|
|
29
29
|
}
|
|
30
30
|
// prettier-ignore
|
|
31
|
-
function FromTuple(
|
|
32
|
-
return
|
|
31
|
+
function FromTuple(types) {
|
|
32
|
+
return types.map((_, indexer) => indexer.toString());
|
|
33
33
|
}
|
|
34
34
|
// prettier-ignore
|
|
35
35
|
function FromArray(_) {
|
|
@@ -55,13 +55,13 @@ function FromPatternProperties(patternProperties) {
|
|
|
55
55
|
}
|
|
56
56
|
/** Returns a tuple of PropertyKeys derived from the given TSchema. */
|
|
57
57
|
// prettier-ignore
|
|
58
|
-
function KeyOfPropertyKeys(
|
|
59
|
-
return ((0, kind_1.IsIntersect)(
|
|
60
|
-
(0, kind_1.IsUnion)(
|
|
61
|
-
(0, kind_1.IsTuple)(
|
|
62
|
-
(0, kind_1.IsArray)(
|
|
63
|
-
(0, kind_1.IsObject)(
|
|
64
|
-
(0, kind_1.IsRecord)(
|
|
58
|
+
function KeyOfPropertyKeys(type) {
|
|
59
|
+
return ((0, kind_1.IsIntersect)(type) ? FromIntersect(type.allOf) :
|
|
60
|
+
(0, kind_1.IsUnion)(type) ? FromUnion(type.anyOf) :
|
|
61
|
+
(0, kind_1.IsTuple)(type) ? FromTuple(type.items ?? []) :
|
|
62
|
+
(0, kind_1.IsArray)(type) ? FromArray(type.items) :
|
|
63
|
+
(0, kind_1.IsObject)(type) ? FromProperties(type.properties) :
|
|
64
|
+
(0, kind_1.IsRecord)(type) ? FromPatternProperties(type.patternProperties) :
|
|
65
65
|
[]);
|
|
66
66
|
}
|
|
67
67
|
// ----------------------------------------------------------------
|
|
@@ -4,13 +4,18 @@ import type { TMappedResult } from '../mapped/index';
|
|
|
4
4
|
import type { SchemaOptions } from '../schema/index';
|
|
5
5
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
6
6
|
import { type TNumber } from '../number/index';
|
|
7
|
+
import { TComputed } from '../computed/index';
|
|
8
|
+
import { type TRef } from '../ref/index';
|
|
7
9
|
import { type TKeyOfPropertyKeys } from './keyof-property-keys';
|
|
8
10
|
import { type TUnionEvaluated } from '../union/index';
|
|
9
11
|
import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
type TFromComputed<Target extends string, Parameters extends TSchema[]> = Ensure<TComputed<'KeyOf', [TComputed<Target, Parameters>]>>;
|
|
13
|
+
type TFromRef<Ref extends string> = Ensure<TComputed<'KeyOf', [TRef<Ref>]>>;
|
|
14
|
+
/** `[Internal]` Used by KeyOfFromMappedResult */
|
|
15
|
+
export type TKeyOfFromType<Type extends TSchema, PropertyKeys extends PropertyKey[] = TKeyOfPropertyKeys<Type>, PropertyKeyTypes extends TSchema[] = TKeyOfPropertyKeysToRest<PropertyKeys>, Result = TUnionEvaluated<PropertyKeyTypes>> = Ensure<Result>;
|
|
16
|
+
export type TKeyOfPropertyKeysToRest<PropertyKeys extends PropertyKey[], Result extends TSchema[] = []> = (PropertyKeys extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TKeyOfPropertyKeysToRest<R, [...Result, TNumber]> : TKeyOfPropertyKeysToRest<R, [...Result, TLiteral<Assert<L, TLiteralValue>>]> : Result);
|
|
17
|
+
export declare function KeyOfPropertyKeysToRest<PropertyKeys extends PropertyKey[]>(propertyKeys: [...PropertyKeys]): TKeyOfPropertyKeysToRest<PropertyKeys>;
|
|
18
|
+
export type TKeyOf<Type extends TSchema> = (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 TMappedResult ? TKeyOfFromMappedResult<Type> : TKeyOfFromType<Type>);
|
|
13
19
|
/** `[Json]` Creates a KeyOf type */
|
|
14
|
-
export declare function KeyOf<
|
|
15
|
-
|
|
16
|
-
export declare function KeyOf<T extends TSchema>(T: T, options?: SchemaOptions): TKeyOf<T>;
|
|
20
|
+
export declare function KeyOf<Type extends TSchema>(type: Type, options?: SchemaOptions): TKeyOf<Type>;
|
|
21
|
+
export {};
|
|
@@ -6,26 +6,35 @@ exports.KeyOf = KeyOf;
|
|
|
6
6
|
const type_1 = require("../create/type");
|
|
7
7
|
const index_1 = require("../literal/index");
|
|
8
8
|
const index_2 = require("../number/index");
|
|
9
|
+
const index_3 = require("../computed/index");
|
|
10
|
+
const index_4 = require("../ref/index");
|
|
9
11
|
const keyof_property_keys_1 = require("./keyof-property-keys");
|
|
10
|
-
const
|
|
12
|
+
const index_5 = require("../union/index");
|
|
11
13
|
const keyof_from_mapped_result_1 = require("./keyof-from-mapped-result");
|
|
12
14
|
// ------------------------------------------------------------------
|
|
13
15
|
// TypeGuard
|
|
14
16
|
// ------------------------------------------------------------------
|
|
15
17
|
const kind_1 = require("../guard/kind");
|
|
16
18
|
// prettier-ignore
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
+
function FromComputed(target, parameters) {
|
|
20
|
+
return (0, index_3.Computed)('KeyOf', [(0, index_3.Computed)(target, parameters)]);
|
|
21
|
+
}
|
|
22
|
+
// prettier-ignore
|
|
23
|
+
function FromRef($ref) {
|
|
24
|
+
return (0, index_3.Computed)('KeyOf', [(0, index_4.Ref)($ref)]);
|
|
25
|
+
}
|
|
26
|
+
// prettier-ignore
|
|
27
|
+
function KeyOfFromType(type, options) {
|
|
28
|
+
const propertyKeys = (0, keyof_property_keys_1.KeyOfPropertyKeys)(type);
|
|
29
|
+
const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
|
|
30
|
+
const result = (0, index_5.UnionEvaluated)(propertyKeyTypes);
|
|
31
|
+
return (0, type_1.CreateType)(result, options);
|
|
32
|
+
}
|
|
33
|
+
// prettier-ignore
|
|
34
|
+
function KeyOfPropertyKeysToRest(propertyKeys) {
|
|
35
|
+
return propertyKeys.map(L => L === '[number]' ? (0, index_2.Number)() : (0, index_1.Literal)(L));
|
|
19
36
|
}
|
|
20
37
|
/** `[Json]` Creates a KeyOf type */
|
|
21
|
-
function KeyOf(
|
|
22
|
-
|
|
23
|
-
return (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(T, options);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const K = (0, keyof_property_keys_1.KeyOfPropertyKeys)(T);
|
|
27
|
-
const S = KeyOfPropertyKeysToRest(K);
|
|
28
|
-
const U = (0, index_3.UnionEvaluated)(S);
|
|
29
|
-
return (0, type_1.CreateType)(U, options);
|
|
30
|
-
}
|
|
38
|
+
function KeyOf(type, options) {
|
|
39
|
+
return ((0, kind_1.IsComputed)(type) ? FromComputed(type.target, type.parameters) : (0, kind_1.IsRef)(type) ? FromRef(type.$ref) : (0, kind_1.IsMappedResult)(type) ? (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(type, options) : KeyOfFromType(type, options));
|
|
31
40
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ensure, Evaluate } from '../helpers/index';
|
|
2
|
+
import { type TSchema } from '../schema/index';
|
|
3
|
+
import { type TArray } from '../array/index';
|
|
4
|
+
import { type TAwaited } from '../awaited/index';
|
|
5
|
+
import { type TAsyncIterator } from '../async-iterator/index';
|
|
6
|
+
import { TComputed } from '../computed/index';
|
|
7
|
+
import { type TConstructor } from '../constructor/index';
|
|
8
|
+
import { type TIndex } from '../indexed/index';
|
|
9
|
+
import { type TFunction } from '../function/index';
|
|
10
|
+
import { type TIntersect, type TIntersectEvaluated } from '../intersect/index';
|
|
11
|
+
import { type TIterator } from '../iterator/index';
|
|
12
|
+
import { type TKeyOf } from '../keyof/index';
|
|
13
|
+
import { type TObject, type TProperties } from '../object/index';
|
|
14
|
+
import { type TOmit } from '../omit/index';
|
|
15
|
+
import { type TPick } from '../pick/index';
|
|
16
|
+
import { type TNever } from '../never/index';
|
|
17
|
+
import { TPartial } from '../partial/index';
|
|
18
|
+
import { type TRecordOrObject } from '../record/index';
|
|
19
|
+
import { type TRef } from '../ref/index';
|
|
20
|
+
import { TRequired } from '../required/index';
|
|
21
|
+
import { type TTuple } from '../tuple/index';
|
|
22
|
+
import { type TUnion, type TUnionEvaluated } from '../union/index';
|
|
23
|
+
type TDerefParameters<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? Left extends TRef<infer Key extends string> ? TDerefParameters<ModuleProperties, Right, [...Result, TDeref<ModuleProperties, Key>]> : TDerefParameters<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
|
|
24
|
+
type TDeref<ModuleProperties extends TProperties, Ref extends string, Result extends TSchema = (Ref extends keyof ModuleProperties ? ModuleProperties[Ref] extends TRef<infer Ref2 extends string> ? TDeref<ModuleProperties, Ref2> : TFromType<ModuleProperties, ModuleProperties[Ref]> : TNever)> = Result;
|
|
25
|
+
type TFromAwaited<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TAwaited<T0> : never);
|
|
26
|
+
type TFromIndex<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TIndex<T0, T1> : never);
|
|
27
|
+
type TFromKeyOf<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TKeyOf<T0> : never);
|
|
28
|
+
type TFromPartial<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TPartial<T0> : never);
|
|
29
|
+
type TFromOmit<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TOmit<T0, T1> : never);
|
|
30
|
+
type TFromPick<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TPick<T0, T1> : never);
|
|
31
|
+
type TFromRecord<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TRecordOrObject<T0, T1> : never);
|
|
32
|
+
type TFromRequired<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TRequired<T0> : never);
|
|
33
|
+
type TFromComputed<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] = TDerefParameters<ModuleProperties, Parameters>> = (Target extends 'Awaited' ? TFromAwaited<Dereferenced> : Target extends 'Index' ? TFromIndex<Dereferenced> : Target extends 'KeyOf' ? TFromKeyOf<Dereferenced> : Target extends 'Partial' ? TFromPartial<Dereferenced> : Target extends 'Omit' ? TFromOmit<Dereferenced> : Target extends 'Pick' ? TFromPick<Dereferenced> : Target extends 'Record' ? TFromRecord<Dereferenced> : Target extends 'Required' ? TFromRequired<Dereferenced> : TNever);
|
|
34
|
+
type TFromObject<ModuleProperties extends TProperties, Properties extends TProperties> = Ensure<TObject<Evaluate<{
|
|
35
|
+
[Key in keyof Properties]: TFromType<ModuleProperties, Properties[Key]>;
|
|
36
|
+
}>>>;
|
|
37
|
+
type TFromConstructor<ModuleProperties extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema> = (TConstructor<TFromRest<ModuleProperties, Parameters>, TFromType<ModuleProperties, InstanceType>>);
|
|
38
|
+
type TFromFunction<ModuleProperties extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema> = Ensure<Ensure<TFunction<TFromRest<ModuleProperties, Parameters>, TFromType<ModuleProperties, ReturnType>>>>;
|
|
39
|
+
type TFromTuple<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TTuple<TFromRest<ModuleProperties, Types>>>);
|
|
40
|
+
type TFromIntersect<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TIntersectEvaluated<TFromRest<ModuleProperties, Types>>>);
|
|
41
|
+
type TFromUnion<ModuleProperties extends TProperties, Types extends TSchema[]> = (Ensure<TUnionEvaluated<TFromRest<ModuleProperties, Types>>>);
|
|
42
|
+
type TFromArray<ModuleProperties extends TProperties, Type extends TSchema> = (Ensure<TArray<TFromType<ModuleProperties, Type>>>);
|
|
43
|
+
type TFromAsyncIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TAsyncIterator<TFromType<ModuleProperties, Type>>);
|
|
44
|
+
type TFromIterator<ModuleProperties extends TProperties, Type extends TSchema> = (TIterator<TFromType<ModuleProperties, Type>>);
|
|
45
|
+
type TFromRest<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromRest<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
|
|
46
|
+
export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TComputed<infer T extends string, infer S extends TSchema[]> ? TFromComputed<ModuleProperties, T, S> : Type extends TObject<infer S extends TProperties> ? TFromObject<ModuleProperties, S> : Type extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TFromConstructor<ModuleProperties, S, R> : Type extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFromFunction<ModuleProperties, S, R> : Type extends TTuple<infer S extends TSchema[]> ? TFromTuple<ModuleProperties, S> : Type extends TIntersect<infer S extends TSchema[]> ? TFromIntersect<ModuleProperties, S> : Type extends TUnion<infer S extends TSchema[]> ? TFromUnion<ModuleProperties, S> : Type extends TArray<infer S extends TSchema> ? TFromArray<ModuleProperties, S> : Type extends TAsyncIterator<infer S extends TSchema> ? TFromAsyncIterator<ModuleProperties, S> : Type extends TIterator<infer S extends TSchema> ? TFromIterator<ModuleProperties, S> : Type);
|
|
47
|
+
export declare function FromType<ModuleProperties extends TProperties, Type extends TSchema>(moduleProperties: ModuleProperties, type: Type): TFromType<ModuleProperties, Type>;
|
|
48
|
+
export type TComputeType<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TFromType<ModuleProperties, ModuleProperties[Key]> : TNever);
|
|
49
|
+
export declare function ComputeType<ModuleProperties extends TProperties, Key extends PropertyKey>(moduleProperties: ModuleProperties, key: Key): TComputeType<ModuleProperties, Key>;
|
|
50
|
+
export type TComputeModuleProperties<ModuleProperties extends TProperties> = Evaluate<{
|
|
51
|
+
[Key in keyof ModuleProperties]: TComputeType<ModuleProperties, Key>;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function ComputeModuleProperties<ModuleProperties extends TProperties>(moduleProperties: ModuleProperties): TComputeModuleProperties<ModuleProperties>;
|
|
54
|
+
export {};
|