typia 7.0.0-dev.20241010 → 7.0.0-dev.20241011
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/lib/index.mjs +7 -0
- package/lib/index.mjs.map +1 -1
- package/lib/internal/$httpParameterReadBigint.d.ts +1 -0
- package/lib/internal/{$httpParameterBigint.js → $httpParameterReadBigint.js} +4 -4
- package/lib/internal/$httpParameterReadBigint.js.map +1 -0
- package/lib/internal/$httpParameterReadBoolean.d.ts +1 -0
- package/lib/internal/{$httpParameterBoolean.js → $httpParameterReadBoolean.js} +4 -4
- package/lib/internal/$httpParameterReadBoolean.js.map +1 -0
- package/lib/internal/$httpParameterReadNumber.d.ts +1 -0
- package/lib/internal/{$httpParameterNumber.js → $httpParameterReadNumber.js} +4 -4
- package/lib/internal/$httpParameterReadNumber.js.map +1 -0
- package/lib/internal/$httpParameterReadString.d.ts +1 -0
- package/lib/internal/$httpParameterReadString.js +8 -0
- package/lib/internal/$httpParameterReadString.js.map +1 -0
- package/lib/json.d.ts +47 -13
- package/lib/json.js +7 -0
- package/lib/json.js.map +1 -1
- package/lib/module.d.ts +1 -0
- package/lib/module.js +1 -0
- package/lib/module.js.map +1 -1
- package/lib/programmers/json/JsonApplicationProgrammer.d.ts +6 -2
- package/lib/programmers/json/JsonApplicationProgrammer.js +200 -75
- package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonSchemasProgrammer.d.ts +6 -0
- package/lib/programmers/json/JsonSchemasProgrammer.js +109 -0
- package/lib/programmers/json/JsonSchemasProgrammer.js.map +1 -0
- package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +57 -39
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/schemas/json/IJsonApplication.d.ts +31 -12
- package/lib/schemas/json/IJsonSchemaList.d.ts +16 -0
- package/lib/schemas/json/IJsonSchemaList.js +3 -0
- package/lib/schemas/json/IJsonSchemaList.js.map +1 -0
- package/lib/transformers/CallExpressionTransformer.js +3 -1
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.js +27 -97
- package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonSchemasTransformer.d.ts +5 -0
- package/lib/transformers/features/json/JsonSchemasTransformer.js +159 -0
- package/lib/transformers/features/json/JsonSchemasTransformer.js.map +1 -0
- package/lib/transformers/features/llm/LlmApplicationTransformer.js +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/MetadataFactory.ts +400 -400
- package/src/factories/internal/metadata/IMetadataIteratorProps.ts +16 -16
- package/src/factories/internal/metadata/emplace_metadata_object.ts +206 -206
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +145 -145
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +32 -32
- package/src/factories/internal/metadata/iterate_metadata_function.ts +88 -88
- package/src/internal/{$httpParameterBigint.ts → $httpParameterReadBigint.ts} +1 -1
- package/src/internal/{$httpParameterBoolean.ts → $httpParameterReadBoolean.ts} +1 -1
- package/src/internal/{$httpParameterNumber.ts → $httpParameterReadNumber.ts} +1 -1
- package/src/internal/$httpParameterReadString.ts +2 -0
- package/src/json.ts +63 -17
- package/src/module.ts +1 -0
- package/src/programmers/json/JsonApplicationProgrammer.ts +249 -72
- package/src/programmers/json/JsonSchemasProgrammer.ts +94 -0
- package/src/programmers/llm/LlmApplicationProgrammer.ts +66 -41
- package/src/schemas/json/IJsonApplication.ts +61 -22
- package/src/schemas/json/IJsonSchemaList.ts +22 -0
- package/src/transformers/CallExpressionTransformer.ts +3 -1
- package/src/transformers/features/json/JsonApplicationTransformer.ts +29 -54
- package/src/transformers/features/json/JsonSchemasTransformer.ts +130 -0
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +1 -1
- package/lib/internal/$httpParameterBigint.d.ts +0 -1
- package/lib/internal/$httpParameterBigint.js.map +0 -1
- package/lib/internal/$httpParameterBoolean.d.ts +0 -1
- package/lib/internal/$httpParameterBoolean.js.map +0 -1
- package/lib/internal/$httpParameterNumber.d.ts +0 -1
- package/lib/internal/$httpParameterNumber.js.map +0 -1
- package/lib/internal/$httpParameterString.d.ts +0 -1
- package/lib/internal/$httpParameterString.js +0 -8
- package/lib/internal/$httpParameterString.js.map +0 -1
- package/src/internal/$httpParameterString.ts +0 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
-
|
|
8
|
-
export interface IMetadataIteratorProps<Type extends ts.Type = ts.Type> {
|
|
9
|
-
options: MetadataFactory.IOptions;
|
|
10
|
-
checker: ts.TypeChecker;
|
|
11
|
-
collection: MetadataCollection;
|
|
12
|
-
errors: MetadataFactory.IError[];
|
|
13
|
-
metadata: Metadata;
|
|
14
|
-
type: Type;
|
|
15
|
-
explore: MetadataFactory.IExplore;
|
|
16
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
6
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
7
|
+
|
|
8
|
+
export interface IMetadataIteratorProps<Type extends ts.Type = ts.Type> {
|
|
9
|
+
options: MetadataFactory.IOptions;
|
|
10
|
+
checker: ts.TypeChecker;
|
|
11
|
+
collection: MetadataCollection;
|
|
12
|
+
errors: MetadataFactory.IError[];
|
|
13
|
+
metadata: Metadata;
|
|
14
|
+
type: Type;
|
|
15
|
+
explore: MetadataFactory.IExplore;
|
|
16
|
+
}
|
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
-
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
-
|
|
7
|
-
import { Writable } from "../../../typings/Writable";
|
|
8
|
-
|
|
9
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
-
|
|
11
|
-
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
13
|
-
import { MetadataHelper } from "./MetadataHelper";
|
|
14
|
-
import { explore_metadata } from "./explore_metadata";
|
|
15
|
-
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
16
|
-
|
|
17
|
-
export const emplace_metadata_object = (
|
|
18
|
-
props: IMetadataIteratorProps,
|
|
19
|
-
): MetadataObject => {
|
|
20
|
-
// EMPLACE OBJECT
|
|
21
|
-
const [obj, newbie] = props.collection.emplace(props.checker, props.type);
|
|
22
|
-
ArrayUtil.add(
|
|
23
|
-
obj.nullables,
|
|
24
|
-
props.metadata.nullable,
|
|
25
|
-
(elem) => elem === props.metadata.nullable,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
if (newbie === false) return obj;
|
|
29
|
-
|
|
30
|
-
// PREPARE ASSETS
|
|
31
|
-
const isClass: boolean = props.type.isClass();
|
|
32
|
-
const isProperty = significant(!!props.options.functional);
|
|
33
|
-
const pred: (node: ts.Declaration) => boolean = isClass
|
|
34
|
-
? (node) => {
|
|
35
|
-
const kind: ts.SyntaxKind | undefined = node
|
|
36
|
-
.getChildren()[0]
|
|
37
|
-
?.getChildren()[0]?.kind;
|
|
38
|
-
return (
|
|
39
|
-
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
40
|
-
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
41
|
-
isProperty(node)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
: (node) => isProperty(node);
|
|
45
|
-
|
|
46
|
-
const insert = (props: {
|
|
47
|
-
key: Metadata;
|
|
48
|
-
value: Metadata;
|
|
49
|
-
symbol: ts.Symbol | undefined;
|
|
50
|
-
filter?: (doc: ts.JSDocTagInfo) => boolean;
|
|
51
|
-
}): MetadataProperty => {
|
|
52
|
-
// COMMENTS AND TAGS
|
|
53
|
-
const description: string | null = props.symbol
|
|
54
|
-
? (CommentFactory.description(props.symbol) ?? null)
|
|
55
|
-
: null;
|
|
56
|
-
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
57
|
-
props.symbol?.getJsDocTags() ?? []
|
|
58
|
-
).filter(props.filter ?? (() => true));
|
|
59
|
-
|
|
60
|
-
// THE PROPERTY
|
|
61
|
-
const property: MetadataProperty = MetadataProperty.create({
|
|
62
|
-
key: props.key,
|
|
63
|
-
value: props.value,
|
|
64
|
-
description,
|
|
65
|
-
jsDocTags,
|
|
66
|
-
});
|
|
67
|
-
obj.properties.push(property);
|
|
68
|
-
return property;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
//----
|
|
72
|
-
// REGULAR PROPERTIES
|
|
73
|
-
//----
|
|
74
|
-
for (const symbol of props.type.getApparentProperties()) {
|
|
75
|
-
// CHECK INTERNAL TAG
|
|
76
|
-
if (
|
|
77
|
-
(symbol.getJsDocTags(props.checker) ?? []).find(
|
|
78
|
-
(tag) => tag.name === "internal",
|
|
79
|
-
) !== undefined
|
|
80
|
-
)
|
|
81
|
-
continue;
|
|
82
|
-
|
|
83
|
-
// CHECK NODE IS A FORMAL PROPERTY
|
|
84
|
-
const [node, type] = (() => {
|
|
85
|
-
const node = symbol.getDeclarations()?.[0] as
|
|
86
|
-
| ts.PropertyDeclaration
|
|
87
|
-
| undefined;
|
|
88
|
-
const type: ts.Type | undefined = node
|
|
89
|
-
? props.checker.getTypeOfSymbolAtLocation(symbol, node)
|
|
90
|
-
: props.checker.getTypeOfPropertyOfType(props.type, symbol.name);
|
|
91
|
-
return [node, type];
|
|
92
|
-
})();
|
|
93
|
-
if ((node && pred(node) === false) || type === undefined) continue;
|
|
94
|
-
|
|
95
|
-
// GET EXACT TYPE
|
|
96
|
-
const key: Metadata = MetadataHelper.literal_to_metadata(symbol.name);
|
|
97
|
-
const value: Metadata = explore_metadata({
|
|
98
|
-
...props,
|
|
99
|
-
type,
|
|
100
|
-
explore: {
|
|
101
|
-
top: false,
|
|
102
|
-
object: obj,
|
|
103
|
-
property: symbol.name,
|
|
104
|
-
parameter: null,
|
|
105
|
-
nested: null,
|
|
106
|
-
aliased: false,
|
|
107
|
-
escaped: false,
|
|
108
|
-
output: false,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
Writable(value).optional = (symbol.flags & ts.SymbolFlags.Optional) !== 0;
|
|
112
|
-
insert({
|
|
113
|
-
key,
|
|
114
|
-
value,
|
|
115
|
-
symbol,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//----
|
|
120
|
-
// DYNAMIC PROPERTIES
|
|
121
|
-
//----
|
|
122
|
-
for (const index of props.checker.getIndexInfosOfType(props.type)) {
|
|
123
|
-
// GET EXACT TYPE
|
|
124
|
-
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
125
|
-
explore_metadata({
|
|
126
|
-
...props,
|
|
127
|
-
type,
|
|
128
|
-
explore: {
|
|
129
|
-
top: false,
|
|
130
|
-
object: obj,
|
|
131
|
-
property,
|
|
132
|
-
parameter: null,
|
|
133
|
-
nested: null,
|
|
134
|
-
aliased: false,
|
|
135
|
-
escaped: false,
|
|
136
|
-
output: false,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
const key: Metadata = analyzer(index.keyType)(null);
|
|
140
|
-
const value: Metadata = analyzer(index.type)({});
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
key.atomics.length +
|
|
144
|
-
key.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0) +
|
|
145
|
-
key.templates.length +
|
|
146
|
-
key.natives.filter(
|
|
147
|
-
(type) =>
|
|
148
|
-
type === "Boolean" ||
|
|
149
|
-
type === "BigInt" ||
|
|
150
|
-
type === "Number" ||
|
|
151
|
-
type === "String",
|
|
152
|
-
).length !==
|
|
153
|
-
key.size()
|
|
154
|
-
)
|
|
155
|
-
props.errors.push({
|
|
156
|
-
name: key.getName(),
|
|
157
|
-
explore: {
|
|
158
|
-
top: false,
|
|
159
|
-
object: obj,
|
|
160
|
-
property: "[key]",
|
|
161
|
-
parameter: null,
|
|
162
|
-
nested: null,
|
|
163
|
-
aliased: false,
|
|
164
|
-
escaped: false,
|
|
165
|
-
output: false,
|
|
166
|
-
},
|
|
167
|
-
messages: [],
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// INSERT WITH REQUIRED CONFIGURATION
|
|
171
|
-
insert({
|
|
172
|
-
key,
|
|
173
|
-
value,
|
|
174
|
-
symbol: index.declaration?.parent
|
|
175
|
-
? props.checker.getSymbolAtLocation(index.declaration.parent)
|
|
176
|
-
: undefined,
|
|
177
|
-
filter: (doc) => doc.name !== "default",
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return obj;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const significant = (functional: boolean) =>
|
|
184
|
-
functional
|
|
185
|
-
? (node: ts.Declaration) => !ts.isAccessor(node)
|
|
186
|
-
: (node: ts.Declaration) =>
|
|
187
|
-
ts.isParameter(node) ||
|
|
188
|
-
ts.isPropertyDeclaration(node) ||
|
|
189
|
-
ts.isPropertyAssignment(node) ||
|
|
190
|
-
ts.isPropertySignature(node) ||
|
|
191
|
-
ts.isTypeLiteralNode(node) ||
|
|
192
|
-
ts.isShorthandPropertyAssignment(node);
|
|
193
|
-
|
|
194
|
-
const iterate_optional_coalesce = (props: {
|
|
195
|
-
metadata: Metadata;
|
|
196
|
-
type: ts.Type;
|
|
197
|
-
}): void => {
|
|
198
|
-
if (props.type.isUnionOrIntersection())
|
|
199
|
-
props.type.types.forEach((child) =>
|
|
200
|
-
iterate_optional_coalesce({
|
|
201
|
-
metadata: props.metadata,
|
|
202
|
-
type: child,
|
|
203
|
-
}),
|
|
204
|
-
);
|
|
205
|
-
else iterate_metadata_coalesce(props);
|
|
206
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataObject } from "../../../schemas/metadata/MetadataObject";
|
|
5
|
+
import { MetadataProperty } from "../../../schemas/metadata/MetadataProperty";
|
|
6
|
+
|
|
7
|
+
import { Writable } from "../../../typings/Writable";
|
|
8
|
+
|
|
9
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
10
|
+
|
|
11
|
+
import { CommentFactory } from "../../CommentFactory";
|
|
12
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
13
|
+
import { MetadataHelper } from "./MetadataHelper";
|
|
14
|
+
import { explore_metadata } from "./explore_metadata";
|
|
15
|
+
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
16
|
+
|
|
17
|
+
export const emplace_metadata_object = (
|
|
18
|
+
props: IMetadataIteratorProps,
|
|
19
|
+
): MetadataObject => {
|
|
20
|
+
// EMPLACE OBJECT
|
|
21
|
+
const [obj, newbie] = props.collection.emplace(props.checker, props.type);
|
|
22
|
+
ArrayUtil.add(
|
|
23
|
+
obj.nullables,
|
|
24
|
+
props.metadata.nullable,
|
|
25
|
+
(elem) => elem === props.metadata.nullable,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (newbie === false) return obj;
|
|
29
|
+
|
|
30
|
+
// PREPARE ASSETS
|
|
31
|
+
const isClass: boolean = props.type.isClass();
|
|
32
|
+
const isProperty = significant(!!props.options.functional);
|
|
33
|
+
const pred: (node: ts.Declaration) => boolean = isClass
|
|
34
|
+
? (node) => {
|
|
35
|
+
const kind: ts.SyntaxKind | undefined = node
|
|
36
|
+
.getChildren()[0]
|
|
37
|
+
?.getChildren()[0]?.kind;
|
|
38
|
+
return (
|
|
39
|
+
kind !== ts.SyntaxKind.PrivateKeyword &&
|
|
40
|
+
kind !== ts.SyntaxKind.ProtectedKeyword &&
|
|
41
|
+
isProperty(node)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
: (node) => isProperty(node);
|
|
45
|
+
|
|
46
|
+
const insert = (props: {
|
|
47
|
+
key: Metadata;
|
|
48
|
+
value: Metadata;
|
|
49
|
+
symbol: ts.Symbol | undefined;
|
|
50
|
+
filter?: (doc: ts.JSDocTagInfo) => boolean;
|
|
51
|
+
}): MetadataProperty => {
|
|
52
|
+
// COMMENTS AND TAGS
|
|
53
|
+
const description: string | null = props.symbol
|
|
54
|
+
? (CommentFactory.description(props.symbol) ?? null)
|
|
55
|
+
: null;
|
|
56
|
+
const jsDocTags: ts.JSDocTagInfo[] = (
|
|
57
|
+
props.symbol?.getJsDocTags() ?? []
|
|
58
|
+
).filter(props.filter ?? (() => true));
|
|
59
|
+
|
|
60
|
+
// THE PROPERTY
|
|
61
|
+
const property: MetadataProperty = MetadataProperty.create({
|
|
62
|
+
key: props.key,
|
|
63
|
+
value: props.value,
|
|
64
|
+
description,
|
|
65
|
+
jsDocTags,
|
|
66
|
+
});
|
|
67
|
+
obj.properties.push(property);
|
|
68
|
+
return property;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//----
|
|
72
|
+
// REGULAR PROPERTIES
|
|
73
|
+
//----
|
|
74
|
+
for (const symbol of props.type.getApparentProperties()) {
|
|
75
|
+
// CHECK INTERNAL TAG
|
|
76
|
+
if (
|
|
77
|
+
(symbol.getJsDocTags(props.checker) ?? []).find(
|
|
78
|
+
(tag) => tag.name === "internal",
|
|
79
|
+
) !== undefined
|
|
80
|
+
)
|
|
81
|
+
continue;
|
|
82
|
+
|
|
83
|
+
// CHECK NODE IS A FORMAL PROPERTY
|
|
84
|
+
const [node, type] = (() => {
|
|
85
|
+
const node = symbol.getDeclarations()?.[0] as
|
|
86
|
+
| ts.PropertyDeclaration
|
|
87
|
+
| undefined;
|
|
88
|
+
const type: ts.Type | undefined = node
|
|
89
|
+
? props.checker.getTypeOfSymbolAtLocation(symbol, node)
|
|
90
|
+
: props.checker.getTypeOfPropertyOfType(props.type, symbol.name);
|
|
91
|
+
return [node, type];
|
|
92
|
+
})();
|
|
93
|
+
if ((node && pred(node) === false) || type === undefined) continue;
|
|
94
|
+
|
|
95
|
+
// GET EXACT TYPE
|
|
96
|
+
const key: Metadata = MetadataHelper.literal_to_metadata(symbol.name);
|
|
97
|
+
const value: Metadata = explore_metadata({
|
|
98
|
+
...props,
|
|
99
|
+
type,
|
|
100
|
+
explore: {
|
|
101
|
+
top: false,
|
|
102
|
+
object: obj,
|
|
103
|
+
property: symbol.name,
|
|
104
|
+
parameter: null,
|
|
105
|
+
nested: null,
|
|
106
|
+
aliased: false,
|
|
107
|
+
escaped: false,
|
|
108
|
+
output: false,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
Writable(value).optional = (symbol.flags & ts.SymbolFlags.Optional) !== 0;
|
|
112
|
+
insert({
|
|
113
|
+
key,
|
|
114
|
+
value,
|
|
115
|
+
symbol,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//----
|
|
120
|
+
// DYNAMIC PROPERTIES
|
|
121
|
+
//----
|
|
122
|
+
for (const index of props.checker.getIndexInfosOfType(props.type)) {
|
|
123
|
+
// GET EXACT TYPE
|
|
124
|
+
const analyzer = (type: ts.Type) => (property: {} | null) =>
|
|
125
|
+
explore_metadata({
|
|
126
|
+
...props,
|
|
127
|
+
type,
|
|
128
|
+
explore: {
|
|
129
|
+
top: false,
|
|
130
|
+
object: obj,
|
|
131
|
+
property,
|
|
132
|
+
parameter: null,
|
|
133
|
+
nested: null,
|
|
134
|
+
aliased: false,
|
|
135
|
+
escaped: false,
|
|
136
|
+
output: false,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
const key: Metadata = analyzer(index.keyType)(null);
|
|
140
|
+
const value: Metadata = analyzer(index.type)({});
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
key.atomics.length +
|
|
144
|
+
key.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0) +
|
|
145
|
+
key.templates.length +
|
|
146
|
+
key.natives.filter(
|
|
147
|
+
(type) =>
|
|
148
|
+
type === "Boolean" ||
|
|
149
|
+
type === "BigInt" ||
|
|
150
|
+
type === "Number" ||
|
|
151
|
+
type === "String",
|
|
152
|
+
).length !==
|
|
153
|
+
key.size()
|
|
154
|
+
)
|
|
155
|
+
props.errors.push({
|
|
156
|
+
name: key.getName(),
|
|
157
|
+
explore: {
|
|
158
|
+
top: false,
|
|
159
|
+
object: obj,
|
|
160
|
+
property: "[key]",
|
|
161
|
+
parameter: null,
|
|
162
|
+
nested: null,
|
|
163
|
+
aliased: false,
|
|
164
|
+
escaped: false,
|
|
165
|
+
output: false,
|
|
166
|
+
},
|
|
167
|
+
messages: [],
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// INSERT WITH REQUIRED CONFIGURATION
|
|
171
|
+
insert({
|
|
172
|
+
key,
|
|
173
|
+
value,
|
|
174
|
+
symbol: index.declaration?.parent
|
|
175
|
+
? props.checker.getSymbolAtLocation(index.declaration.parent)
|
|
176
|
+
: undefined,
|
|
177
|
+
filter: (doc) => doc.name !== "default",
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return obj;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const significant = (functional: boolean) =>
|
|
184
|
+
functional
|
|
185
|
+
? (node: ts.Declaration) => !ts.isAccessor(node)
|
|
186
|
+
: (node: ts.Declaration) =>
|
|
187
|
+
ts.isParameter(node) ||
|
|
188
|
+
ts.isPropertyDeclaration(node) ||
|
|
189
|
+
ts.isPropertyAssignment(node) ||
|
|
190
|
+
ts.isPropertySignature(node) ||
|
|
191
|
+
ts.isTypeLiteralNode(node) ||
|
|
192
|
+
ts.isShorthandPropertyAssignment(node);
|
|
193
|
+
|
|
194
|
+
const iterate_optional_coalesce = (props: {
|
|
195
|
+
metadata: Metadata;
|
|
196
|
+
type: ts.Type;
|
|
197
|
+
}): void => {
|
|
198
|
+
if (props.type.isUnionOrIntersection())
|
|
199
|
+
props.type.types.forEach((child) =>
|
|
200
|
+
iterate_optional_coalesce({
|
|
201
|
+
metadata: props.metadata,
|
|
202
|
+
type: child,
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
else iterate_metadata_coalesce(props);
|
|
206
|
+
};
|