typia 4.0.3-dev.20230606 → 4.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "4.0.3-dev.20230606",
3
+ "version": "4.0.3",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
package/src/Primitive.ts CHANGED
@@ -1,125 +1,125 @@
1
- /**
2
- * Primitive type.
3
- *
4
- * `Primitive` is a type of TMP (Type Meta Programming) type who converts its argument as a
5
- * primitive type.
6
- *
7
- * If the target argument is a built-in class who returns its origin primitive type through
8
- * the `valueOf()` method like the `String` or `Number`, its return type would be the
9
- * `string` or `number`.
10
- *
11
- * Otherwise, the target argument is a type of custom class, all of its custom method would
12
- * be erased and its prototype would be changed to the primitive `object`. Therefore, return
13
- * type of the TMP type finally be the primitive object.
14
- *
15
- * In addition, if the target argument is a type of custom class and it has a special
16
- * method `toJSON()`, return type of this `Primitive` would be not `Primitive<Instance>`
17
- * but `Primitive<ReturnType<Instance.toJSON>>`.
18
- *
19
- * Before | After
20
- * ------------------------|----------------------------------------
21
- * `Boolean` | `boolean`
22
- * `Number` | `number`
23
- * `String` | `string`
24
- * `Class` | `object`
25
- * `Class` with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>`
26
- * Others | No change
27
- *
28
- * @template Instance Target argument type.
29
- * @author Jenogho Nam - https://github.com/samchon
30
- */
31
- export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
32
- ? T
33
- : PrimitiveMain<T>;
34
-
35
- type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
36
-
37
- type PrimitiveMain<Instance> = ValueOf<Instance> extends object
38
- ? Instance extends object
39
- ? Instance extends NativeClass
40
- ? {}
41
- : Instance extends IJsonable<infer Raw>
42
- ? ValueOf<Raw> extends object
43
- ? Raw extends object
44
- ? PrimitiveObject<Raw> // object would be primitified
45
- : never // cannot be
46
- : ValueOf<Raw> // atomic value
47
- : PrimitiveObject<Instance> // object would be primitified
48
- : never // cannot be
49
- : ValueOf<Instance>;
50
-
51
- type PrimitiveObject<Instance extends object> = Instance extends Array<infer T>
52
- ? IsTuple<Instance> extends true
53
- ? PrimitiveTuple<Instance>
54
- : PrimitiveMain<T>[]
55
- : {
56
- [P in keyof Instance]: Instance[P] extends Function
57
- ? never
58
- : PrimitiveMain<Instance[P]>;
59
- };
60
-
61
- type PrimitiveTuple<T extends readonly any[]> = T extends []
62
- ? []
63
- : T extends [infer F]
64
- ? [PrimitiveMain<F>]
65
- : T extends [infer F, ...infer Rest extends readonly any[]]
66
- ? [PrimitiveMain<F>, ...PrimitiveTuple<Rest>]
67
- : T extends [(infer F)?]
68
- ? [PrimitiveMain<F>?]
69
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
70
- ? [PrimitiveMain<F>?, ...PrimitiveTuple<Rest>]
71
- : [];
72
-
73
- type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
74
- ? boolean
75
- : IsValueOf<Instance, Number> extends true
76
- ? number
77
- : IsValueOf<Instance, String> extends true
78
- ? string
79
- : Instance;
80
-
81
- type NativeClass =
82
- | Set<any>
83
- | Map<any, any>
84
- | WeakSet<any>
85
- | WeakMap<any, any>
86
- | Uint8Array
87
- | Uint8ClampedArray
88
- | Uint16Array
89
- | Uint32Array
90
- | BigUint64Array
91
- | Int8Array
92
- | Int16Array
93
- | Int32Array
94
- | BigInt64Array
95
- | Float32Array
96
- | Float64Array
97
- | ArrayBuffer
98
- | SharedArrayBuffer
99
- | DataView;
100
-
101
- type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
102
- never,
103
- ]
104
- ? false
105
- : T extends readonly any[]
106
- ? number extends T["length"]
107
- ? false
108
- : true
109
- : false;
110
-
111
- type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
112
- ? Object extends IValueOf<infer Primitive>
113
- ? Instance extends Primitive
114
- ? false
115
- : true // not Primitive, but Object
116
- : false // cannot be
117
- : false;
118
-
119
- interface IValueOf<T> {
120
- valueOf(): T;
121
- }
122
-
123
- interface IJsonable<T> {
124
- toJSON(): T;
125
- }
1
+ /**
2
+ * Primitive type.
3
+ *
4
+ * `Primitive` is a type of TMP (Type Meta Programming) type who converts its argument as a
5
+ * primitive type.
6
+ *
7
+ * If the target argument is a built-in class who returns its origin primitive type through
8
+ * the `valueOf()` method like the `String` or `Number`, its return type would be the
9
+ * `string` or `number`.
10
+ *
11
+ * Otherwise, the target argument is a type of custom class, all of its custom method would
12
+ * be erased and its prototype would be changed to the primitive `object`. Therefore, return
13
+ * type of the TMP type finally be the primitive object.
14
+ *
15
+ * In addition, if the target argument is a type of custom class and it has a special
16
+ * method `toJSON()`, return type of this `Primitive` would be not `Primitive<Instance>`
17
+ * but `Primitive<ReturnType<Instance.toJSON>>`.
18
+ *
19
+ * Before | After
20
+ * ------------------------|----------------------------------------
21
+ * `Boolean` | `boolean`
22
+ * `Number` | `number`
23
+ * `String` | `string`
24
+ * `Class` | `object`
25
+ * `Class` with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>`
26
+ * Others | No change
27
+ *
28
+ * @template Instance Target argument type.
29
+ * @author Jenogho Nam - https://github.com/samchon
30
+ */
31
+ export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
32
+ ? T
33
+ : PrimitiveMain<T>;
34
+
35
+ type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
36
+
37
+ type PrimitiveMain<Instance> = ValueOf<Instance> extends object
38
+ ? Instance extends object
39
+ ? Instance extends NativeClass
40
+ ? {}
41
+ : Instance extends IJsonable<infer Raw>
42
+ ? ValueOf<Raw> extends object
43
+ ? Raw extends object
44
+ ? PrimitiveObject<Raw> // object would be primitified
45
+ : never // cannot be
46
+ : ValueOf<Raw> // atomic value
47
+ : PrimitiveObject<Instance> // object would be primitified
48
+ : never // cannot be
49
+ : ValueOf<Instance>;
50
+
51
+ type PrimitiveObject<Instance extends object> = Instance extends Array<infer T>
52
+ ? IsTuple<Instance> extends true
53
+ ? PrimitiveTuple<Instance>
54
+ : PrimitiveMain<T>[]
55
+ : {
56
+ [P in keyof Instance]: Instance[P] extends Function
57
+ ? never
58
+ : PrimitiveMain<Instance[P]>;
59
+ };
60
+
61
+ type PrimitiveTuple<T extends readonly any[]> = T extends []
62
+ ? []
63
+ : T extends [infer F]
64
+ ? [PrimitiveMain<F>]
65
+ : T extends [infer F, ...infer Rest extends readonly any[]]
66
+ ? [PrimitiveMain<F>, ...PrimitiveTuple<Rest>]
67
+ : T extends [(infer F)?]
68
+ ? [PrimitiveMain<F>?]
69
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
70
+ ? [PrimitiveMain<F>?, ...PrimitiveTuple<Rest>]
71
+ : [];
72
+
73
+ type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
74
+ ? boolean
75
+ : IsValueOf<Instance, Number> extends true
76
+ ? number
77
+ : IsValueOf<Instance, String> extends true
78
+ ? string
79
+ : Instance;
80
+
81
+ type NativeClass =
82
+ | Set<any>
83
+ | Map<any, any>
84
+ | WeakSet<any>
85
+ | WeakMap<any, any>
86
+ | Uint8Array
87
+ | Uint8ClampedArray
88
+ | Uint16Array
89
+ | Uint32Array
90
+ | BigUint64Array
91
+ | Int8Array
92
+ | Int16Array
93
+ | Int32Array
94
+ | BigInt64Array
95
+ | Float32Array
96
+ | Float64Array
97
+ | ArrayBuffer
98
+ | SharedArrayBuffer
99
+ | DataView;
100
+
101
+ type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
102
+ never,
103
+ ]
104
+ ? false
105
+ : T extends readonly any[]
106
+ ? number extends T["length"]
107
+ ? false
108
+ : true
109
+ : false;
110
+
111
+ type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
112
+ ? Object extends IValueOf<infer Primitive>
113
+ ? Instance extends Primitive
114
+ ? false
115
+ : true // not Primitive, but Object
116
+ : false // cannot be
117
+ : false;
118
+
119
+ interface IValueOf<T> {
120
+ valueOf(): T;
121
+ }
122
+
123
+ interface IJsonable<T> {
124
+ toJSON(): T;
125
+ }
@@ -1,140 +1,140 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../../../metadata/Metadata";
4
- import { MetadataObject } from "../../../metadata/MetadataObject";
5
- import { MetadataProperty } from "../../../metadata/MetadataProperty";
6
-
7
- import { Writable } from "../../../typings/Writable";
8
-
9
- import { ArrayUtil } from "../../../utils/ArrayUtil";
10
-
11
- import { CommentFactory } from "../../CommentFactory";
12
- import { MetadataCollection } from "../../MetadataCollection";
13
- import { MetadataFactory } from "../../MetadataFactory";
14
- import { MetadataTagFactory } from "../../MetadataTagFactory";
15
- import { MetadataHelper } from "./MetadataHelper";
16
- import { explore_metadata } from "./explore_metadata";
17
-
18
- export const emplace_metadata_object =
19
- (checker: ts.TypeChecker) =>
20
- (options: MetadataFactory.IOptions) =>
21
- (collection: MetadataCollection) =>
22
- (parent: ts.Type, nullable: boolean): MetadataObject => {
23
- // EMPLACE OBJECT
24
- const [obj, newbie] = collection.emplace(checker, parent);
25
- ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
26
-
27
- if (newbie === false) return obj;
28
-
29
- // PREPARE ASSETS
30
- const isClass: boolean = parent.isClass();
31
- const pred: (node: ts.Declaration) => boolean = isClass
32
- ? (node) => {
33
- const kind: ts.SyntaxKind | undefined = node
34
- .getChildren()[0]
35
- ?.getChildren()[0]?.kind;
36
- return (
37
- kind !== ts.SyntaxKind.PrivateKeyword &&
38
- kind !== ts.SyntaxKind.ProtectedKeyword &&
39
- (ts.isParameter(node) || isProperty(node))
40
- );
41
- }
42
- : (node) => isProperty(node);
43
-
44
- const insert =
45
- (key: Metadata) =>
46
- (value: Metadata) =>
47
- (identifier: () => string) =>
48
- (
49
- symbol: ts.Symbol | undefined,
50
- filter?: (doc: ts.JSDocTagInfo) => boolean,
51
- ): MetadataProperty => {
52
- // COMMENTS AND TAGS
53
- const description: string | null = symbol
54
- ? CommentFactory.description(symbol) ?? null
55
- : null;
56
- const jsDocTags: ts.JSDocTagInfo[] = (
57
- symbol?.getJsDocTags() ?? []
58
- ).filter(filter ?? (() => true));
59
-
60
- // THE PROPERTY
61
- const property = MetadataProperty.create({
62
- key,
63
- value,
64
- description,
65
- jsDocTags,
66
- tags: MetadataTagFactory.generate(value)(jsDocTags)(() =>
67
- identifier(),
68
- ),
69
- });
70
- obj.properties.push(property);
71
- return property;
72
- };
73
-
74
- //----
75
- // REGULAR PROPERTIES
76
- //----
77
- for (const prop of parent.getApparentProperties()) {
78
- // CHECK INTERNAL TAG
79
- if (
80
- (prop.getJsDocTags(checker) ?? []).find(
81
- (tag) => tag.name === "internal",
82
- ) !== undefined
83
- )
84
- continue;
85
-
86
- // CHECK NODE IS A FORMAL PROPERTY
87
- const [node, type] = (() => {
88
- const node = (prop.getDeclarations() ?? [])[0] as
89
- | ts.PropertyDeclaration
90
- | undefined;
91
- const type: ts.Type | undefined = node
92
- ? checker.getTypeOfSymbolAtLocation(prop, node)
93
- : "getTypeOfPropertyOfType" in checker
94
- ? (checker as any).getTypeOfPropertyOfType(
95
- parent,
96
- prop.name,
97
- )
98
- : undefined;
99
- return [node, type];
100
- })();
101
- if ((node && pred(node) === false) || type === undefined) continue;
102
-
103
- // GET EXACT TYPE
104
- const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
105
- const value: Metadata = explore_metadata(checker)(options)(
106
- collection,
107
- )(type, false);
108
-
109
- // OPTIONAL, BUT CAN BE RQUIRED BY `Required<T>` TYPE
110
- if (node?.questionToken && (value.required === false || value.any))
111
- Writable(value).optional = true;
112
- insert(key)(value)(() => `${obj.name}.${prop.name}`)(prop);
113
- }
114
-
115
- //----
116
- // DYNAMIC PROPERTIES
117
- //----
118
- for (const index of checker.getIndexInfosOfType(parent)) {
119
- // GET EXACT TYPE
120
- const analyzer = (type: ts.Type) =>
121
- explore_metadata(checker)(options)(collection)(type, false);
122
- const key: Metadata = analyzer(index.keyType);
123
- const value: Metadata = analyzer(index.type);
124
-
125
- // INSERT WITH REQUIRED CONFIGURATION
126
- insert(key)(value)(() => `${obj.name}[${key.getName()}]`)(
127
- index.declaration?.parent
128
- ? checker.getSymbolAtLocation(index.declaration.parent)
129
- : undefined,
130
- (doc) => doc.name !== "default",
131
- );
132
- }
133
- return obj;
134
- };
135
-
136
- const isProperty = (node: ts.Declaration) =>
137
- ts.isPropertyDeclaration(node) ||
138
- ts.isPropertyAssignment(node) ||
139
- ts.isPropertySignature(node) ||
140
- ts.isTypeLiteralNode(node);
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../../../metadata/Metadata";
4
+ import { MetadataObject } from "../../../metadata/MetadataObject";
5
+ import { MetadataProperty } from "../../../metadata/MetadataProperty";
6
+
7
+ import { Writable } from "../../../typings/Writable";
8
+
9
+ import { ArrayUtil } from "../../../utils/ArrayUtil";
10
+
11
+ import { CommentFactory } from "../../CommentFactory";
12
+ import { MetadataCollection } from "../../MetadataCollection";
13
+ import { MetadataFactory } from "../../MetadataFactory";
14
+ import { MetadataTagFactory } from "../../MetadataTagFactory";
15
+ import { MetadataHelper } from "./MetadataHelper";
16
+ import { explore_metadata } from "./explore_metadata";
17
+
18
+ export const emplace_metadata_object =
19
+ (checker: ts.TypeChecker) =>
20
+ (options: MetadataFactory.IOptions) =>
21
+ (collection: MetadataCollection) =>
22
+ (parent: ts.Type, nullable: boolean): MetadataObject => {
23
+ // EMPLACE OBJECT
24
+ const [obj, newbie] = collection.emplace(checker, parent);
25
+ ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
26
+
27
+ if (newbie === false) return obj;
28
+
29
+ // PREPARE ASSETS
30
+ const isClass: boolean = parent.isClass();
31
+ const pred: (node: ts.Declaration) => boolean = isClass
32
+ ? (node) => {
33
+ const kind: ts.SyntaxKind | undefined = node
34
+ .getChildren()[0]
35
+ ?.getChildren()[0]?.kind;
36
+ return (
37
+ kind !== ts.SyntaxKind.PrivateKeyword &&
38
+ kind !== ts.SyntaxKind.ProtectedKeyword &&
39
+ (ts.isParameter(node) || isProperty(node))
40
+ );
41
+ }
42
+ : (node) => isProperty(node);
43
+
44
+ const insert =
45
+ (key: Metadata) =>
46
+ (value: Metadata) =>
47
+ (identifier: () => string) =>
48
+ (
49
+ symbol: ts.Symbol | undefined,
50
+ filter?: (doc: ts.JSDocTagInfo) => boolean,
51
+ ): MetadataProperty => {
52
+ // COMMENTS AND TAGS
53
+ const description: string | null = symbol
54
+ ? CommentFactory.description(symbol) ?? null
55
+ : null;
56
+ const jsDocTags: ts.JSDocTagInfo[] = (
57
+ symbol?.getJsDocTags() ?? []
58
+ ).filter(filter ?? (() => true));
59
+
60
+ // THE PROPERTY
61
+ const property = MetadataProperty.create({
62
+ key,
63
+ value,
64
+ description,
65
+ jsDocTags,
66
+ tags: MetadataTagFactory.generate(value)(jsDocTags)(() =>
67
+ identifier(),
68
+ ),
69
+ });
70
+ obj.properties.push(property);
71
+ return property;
72
+ };
73
+
74
+ //----
75
+ // REGULAR PROPERTIES
76
+ //----
77
+ for (const prop of parent.getApparentProperties()) {
78
+ // CHECK INTERNAL TAG
79
+ if (
80
+ (prop.getJsDocTags(checker) ?? []).find(
81
+ (tag) => tag.name === "internal",
82
+ ) !== undefined
83
+ )
84
+ continue;
85
+
86
+ // CHECK NODE IS A FORMAL PROPERTY
87
+ const [node, type] = (() => {
88
+ const node = (prop.getDeclarations() ?? [])[0] as
89
+ | ts.PropertyDeclaration
90
+ | undefined;
91
+ const type: ts.Type | undefined = node
92
+ ? checker.getTypeOfSymbolAtLocation(prop, node)
93
+ : "getTypeOfPropertyOfType" in checker
94
+ ? (checker as any).getTypeOfPropertyOfType(
95
+ parent,
96
+ prop.name,
97
+ )
98
+ : undefined;
99
+ return [node, type];
100
+ })();
101
+ if ((node && pred(node) === false) || type === undefined) continue;
102
+
103
+ // GET EXACT TYPE
104
+ const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
105
+ const value: Metadata = explore_metadata(checker)(options)(
106
+ collection,
107
+ )(type, false);
108
+
109
+ // OPTIONAL, BUT CAN BE RQUIRED BY `Required<T>` TYPE
110
+ if (node?.questionToken && (value.required === false || value.any))
111
+ Writable(value).optional = true;
112
+ insert(key)(value)(() => `${obj.name}.${prop.name}`)(prop);
113
+ }
114
+
115
+ //----
116
+ // DYNAMIC PROPERTIES
117
+ //----
118
+ for (const index of checker.getIndexInfosOfType(parent)) {
119
+ // GET EXACT TYPE
120
+ const analyzer = (type: ts.Type) =>
121
+ explore_metadata(checker)(options)(collection)(type, false);
122
+ const key: Metadata = analyzer(index.keyType);
123
+ const value: Metadata = analyzer(index.type);
124
+
125
+ // INSERT WITH REQUIRED CONFIGURATION
126
+ insert(key)(value)(() => `${obj.name}[${key.getName()}]`)(
127
+ index.declaration?.parent
128
+ ? checker.getSymbolAtLocation(index.declaration.parent)
129
+ : undefined,
130
+ (doc) => doc.name !== "default",
131
+ );
132
+ }
133
+ return obj;
134
+ };
135
+
136
+ const isProperty = (node: ts.Declaration) =>
137
+ ts.isPropertyDeclaration(node) ||
138
+ ts.isPropertyAssignment(node) ||
139
+ ts.isPropertySignature(node) ||
140
+ ts.isTypeLiteralNode(node);
@@ -1,53 +1,53 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../../../metadata/Metadata";
4
- import { MetadataTuple } from "../../../metadata/MetadataTuple";
5
-
6
- import { Writable } from "../../../typings/Writable";
7
-
8
- import { ArrayUtil } from "../../../utils/ArrayUtil";
9
-
10
- import { MetadataCollection } from "../../MetadataCollection";
11
- import { MetadataFactory } from "../../MetadataFactory";
12
- import { explore_metadata } from "./explore_metadata";
13
-
14
- export const emplace_metadata_tuple =
15
- (checker: ts.TypeChecker) =>
16
- (options: MetadataFactory.IOptions) =>
17
- (collection: MetadataCollection) =>
18
- (type: ts.TupleType, nullable: boolean): MetadataTuple => {
19
- // CHECK EXISTENCE
20
- const [tuple, newbie, closure] = collection.emplaceTuple(checker, type);
21
- ArrayUtil.add(tuple.nullables, nullable);
22
- if (newbie === false) return tuple;
23
-
24
- // CONSTRUCT ELEMENT TYPES
25
- const flagList: readonly ts.ElementFlags[] =
26
- type.elementFlags ??
27
- (type.target as ts.TupleType)?.elementFlags ??
28
- [];
29
- const elements: Metadata[] = checker
30
- .getTypeArguments(type as ts.TypeReference)
31
- .map((elem, i) => {
32
- const child: Metadata = explore_metadata(checker)(options)(
33
- collection,
34
- )(elem, false, false);
35
-
36
- // CHECK OPTIONAL
37
- const flag: ts.ElementFlags | undefined = flagList[i];
38
- if (
39
- flag === ts.ElementFlags.Optional &&
40
- (child.required === false || child.any === true)
41
- )
42
- Writable(child).optional = true;
43
-
44
- // REST TYPE
45
- if (flag !== ts.ElementFlags.Rest) return child;
46
- const wrapper: Metadata = Metadata.initialize();
47
- Writable(wrapper).rest = child;
48
- return wrapper;
49
- });
50
- closure(elements);
51
-
52
- return tuple;
53
- };
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../../../metadata/Metadata";
4
+ import { MetadataTuple } from "../../../metadata/MetadataTuple";
5
+
6
+ import { Writable } from "../../../typings/Writable";
7
+
8
+ import { ArrayUtil } from "../../../utils/ArrayUtil";
9
+
10
+ import { MetadataCollection } from "../../MetadataCollection";
11
+ import { MetadataFactory } from "../../MetadataFactory";
12
+ import { explore_metadata } from "./explore_metadata";
13
+
14
+ export const emplace_metadata_tuple =
15
+ (checker: ts.TypeChecker) =>
16
+ (options: MetadataFactory.IOptions) =>
17
+ (collection: MetadataCollection) =>
18
+ (type: ts.TupleType, nullable: boolean): MetadataTuple => {
19
+ // CHECK EXISTENCE
20
+ const [tuple, newbie, closure] = collection.emplaceTuple(checker, type);
21
+ ArrayUtil.add(tuple.nullables, nullable);
22
+ if (newbie === false) return tuple;
23
+
24
+ // CONSTRUCT ELEMENT TYPES
25
+ const flagList: readonly ts.ElementFlags[] =
26
+ type.elementFlags ??
27
+ (type.target as ts.TupleType)?.elementFlags ??
28
+ [];
29
+ const elements: Metadata[] = checker
30
+ .getTypeArguments(type as ts.TypeReference)
31
+ .map((elem, i) => {
32
+ const child: Metadata = explore_metadata(checker)(options)(
33
+ collection,
34
+ )(elem, false, false);
35
+
36
+ // CHECK OPTIONAL
37
+ const flag: ts.ElementFlags | undefined = flagList[i];
38
+ if (
39
+ flag === ts.ElementFlags.Optional &&
40
+ (child.required === false || child.any === true)
41
+ )
42
+ Writable(child).optional = true;
43
+
44
+ // REST TYPE
45
+ if (flag !== ts.ElementFlags.Rest) return child;
46
+ const wrapper: Metadata = Metadata.initialize();
47
+ Writable(wrapper).rest = child;
48
+ return wrapper;
49
+ });
50
+ closure(elements);
51
+
52
+ return tuple;
53
+ };