@trapi/metadata 0.1.6 → 0.1.7
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/dist/cache/driver.d.ts +1 -1
- package/dist/cache/driver.d.ts.map +1 -1
- package/dist/cache/driver.js +3 -5
- package/dist/cache/driver.js.map +1 -1
- package/dist/cache/type.d.ts +1 -1
- package/dist/cache/type.d.ts.map +1 -1
- package/dist/cache/utils.d.ts +1 -1
- package/dist/cache/utils.d.ts.map +1 -1
- package/dist/cache/utils.js +3 -3
- package/dist/cache/utils.js.map +1 -1
- package/dist/config/path.js.map +1 -1
- package/dist/decorator/functions.d.ts.map +1 -1
- package/dist/decorator/functions.js +9 -13
- package/dist/decorator/functions.js.map +1 -1
- package/dist/decorator/index.d.ts +1 -1
- package/dist/decorator/mapper/index.d.ts +3 -3
- package/dist/decorator/mapper/index.d.ts.map +1 -1
- package/dist/decorator/mapper/index.js +5 -9
- package/dist/decorator/mapper/index.js.map +1 -1
- package/dist/decorator/mapper/maps/decorators-express.d.ts +1 -1
- package/dist/decorator/mapper/maps/decorators-express.d.ts.map +1 -1
- package/dist/decorator/mapper/maps/decorators-express.js +33 -33
- package/dist/decorator/mapper/maps/internal.d.ts +1 -1
- package/dist/decorator/mapper/maps/internal.d.ts.map +1 -1
- package/dist/decorator/mapper/maps/internal.js +31 -27
- package/dist/decorator/mapper/maps/internal.js.map +1 -1
- package/dist/decorator/mapper/maps/typescript-rest.d.ts +1 -1
- package/dist/decorator/mapper/maps/typescript-rest.d.ts.map +1 -1
- package/dist/decorator/mapper/maps/typescript-rest.js +38 -38
- package/dist/decorator/mapper/maps/typescript-rest.js.map +1 -1
- package/dist/decorator/mapper/utils.d.ts +1 -1
- package/dist/decorator/mapper/utils.d.ts.map +1 -1
- package/dist/decorator/mapper/utils.js +1 -1
- package/dist/decorator/mapper/utils.js.map +1 -1
- package/dist/decorator/representation/index.d.ts +1 -1
- package/dist/decorator/representation/index.d.ts.map +1 -1
- package/dist/decorator/representation/index.js.map +1 -1
- package/dist/decorator/representation/property/utils.d.ts +1 -1
- package/dist/decorator/representation/property/utils.d.ts.map +1 -1
- package/dist/decorator/representation/property/utils.js +3 -3
- package/dist/decorator/representation/property/utils.js.map +1 -1
- package/dist/decorator/type.d.ts.map +1 -1
- package/dist/decorator/utils/node.d.ts +1 -1
- package/dist/decorator/utils/node.d.ts.map +1 -1
- package/dist/decorator/utils/node.js +4 -6
- package/dist/decorator/utils/node.js.map +1 -1
- package/dist/decorator/utils/validator.d.ts +2 -2
- package/dist/decorator/utils/validator.d.ts.map +1 -1
- package/dist/decorator/utils/validator.js +8 -8
- package/dist/decorator/utils/validator.js.map +1 -1
- package/dist/generator/controller.d.ts +1 -1
- package/dist/generator/controller.d.ts.map +1 -1
- package/dist/generator/controller.js.map +1 -1
- package/dist/generator/endpoint.d.ts +2 -2
- package/dist/generator/endpoint.d.ts.map +1 -1
- package/dist/generator/endpoint.js +14 -16
- package/dist/generator/endpoint.js.map +1 -1
- package/dist/generator/method.d.ts +1 -1
- package/dist/generator/method.d.ts.map +1 -1
- package/dist/generator/method.js +10 -10
- package/dist/generator/method.js.map +1 -1
- package/dist/generator/module.d.ts +3 -3
- package/dist/generator/module.d.ts.map +1 -1
- package/dist/generator/module.js +16 -16
- package/dist/generator/module.js.map +1 -1
- package/dist/generator/parameter.d.ts +1 -1
- package/dist/generator/parameter.d.ts.map +1 -1
- package/dist/generator/parameter.js +26 -27
- package/dist/generator/parameter.js.map +1 -1
- package/dist/resolver/type-node.d.ts +1 -1
- package/dist/resolver/type-node.d.ts.map +1 -1
- package/dist/resolver/type-node.js +106 -138
- package/dist/resolver/type-node.js.map +1 -1
- package/dist/resolver/type.d.ts +1 -1
- package/dist/resolver/type.d.ts.map +1 -1
- package/dist/resolver/utils/initializer.d.ts +1 -1
- package/dist/resolver/utils/initializer.d.ts.map +1 -1
- package/dist/resolver/utils/initializer.js +11 -13
- package/dist/resolver/utils/initializer.js.map +1 -1
- package/dist/resolver/utils/validator.d.ts +1 -1
- package/dist/resolver/utils/validator.d.ts.map +1 -1
- package/dist/resolver/utils/validator.js +6 -10
- package/dist/resolver/utils/validator.js.map +1 -1
- package/dist/type.d.ts +3 -3
- package/dist/type.d.ts.map +1 -1
- package/dist/utils/generator.d.ts +2 -2
- package/dist/utils/generator.d.ts.map +1 -1
- package/dist/utils/generator.js +1 -1
- package/dist/utils/generator.js.map +1 -1
- package/dist/utils/js-doc.d.ts.map +1 -1
- package/dist/utils/js-doc.js +6 -10
- package/dist/utils/js-doc.js.map +1 -1
- package/dist/utils/validator.d.ts +2 -2
- package/dist/utils/validator.d.ts.map +1 -1
- package/dist/utils/validator.js +2 -2
- package/dist/utils/validator.js.map +1 -1
- package/package.json +6 -6
|
@@ -28,10 +28,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
exports.TypeNodeResolver = void 0;
|
|
29
29
|
const ts = __importStar(require("typescript"));
|
|
30
30
|
const metadata_utils_1 = require("@trapi/metadata-utils");
|
|
31
|
+
const decorator_1 = require("../decorator");
|
|
31
32
|
const utils_1 = require("../utils");
|
|
32
33
|
const error_1 = require("./error");
|
|
33
34
|
const utils_2 = require("./utils");
|
|
34
|
-
const decorator_1 = require("../decorator");
|
|
35
35
|
const localReferenceTypeCache = {};
|
|
36
36
|
const inProgressTypes = {};
|
|
37
37
|
function getPropertyValidators(property) {
|
|
@@ -48,25 +48,23 @@ class TypeNodeResolver {
|
|
|
48
48
|
if (syntaxKind === ts.SyntaxKind.NumberKeyword) {
|
|
49
49
|
return 'number';
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
if (syntaxKind === ts.SyntaxKind.StringKeyword) {
|
|
52
52
|
return 'string';
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
if (syntaxKind === ts.SyntaxKind.BooleanKeyword) {
|
|
55
55
|
return 'boolean';
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
if (syntaxKind === ts.SyntaxKind.VoidKeyword) {
|
|
58
58
|
return 'void';
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
60
|
+
return undefined;
|
|
63
61
|
};
|
|
64
62
|
}
|
|
65
63
|
static clearCache() {
|
|
66
|
-
Object.keys(localReferenceTypeCache).forEach(key => {
|
|
64
|
+
Object.keys(localReferenceTypeCache).forEach((key) => {
|
|
67
65
|
delete localReferenceTypeCache[key];
|
|
68
66
|
});
|
|
69
|
-
Object.keys(inProgressTypes).forEach(key => {
|
|
67
|
+
Object.keys(inProgressTypes).forEach((key) => {
|
|
70
68
|
delete inProgressTypes[key];
|
|
71
69
|
});
|
|
72
70
|
}
|
|
@@ -88,18 +86,14 @@ class TypeNodeResolver {
|
|
|
88
86
|
};
|
|
89
87
|
}
|
|
90
88
|
if (ts.isUnionTypeNode(this.typeNode)) {
|
|
91
|
-
const types = this.typeNode.types.map(type =>
|
|
92
|
-
return new TypeNodeResolver(type, this.current, this.parentNode, this.context).resolve();
|
|
93
|
-
});
|
|
89
|
+
const types = this.typeNode.types.map((type) => new TypeNodeResolver(type, this.current, this.parentNode, this.context).resolve());
|
|
94
90
|
return {
|
|
95
91
|
typeName: 'union',
|
|
96
92
|
members: types,
|
|
97
93
|
};
|
|
98
94
|
}
|
|
99
95
|
if (ts.isIntersectionTypeNode(this.typeNode)) {
|
|
100
|
-
const types = this.typeNode.types.map(type =>
|
|
101
|
-
return new TypeNodeResolver(type, this.current, this.parentNode, this.context).resolve();
|
|
102
|
-
});
|
|
96
|
+
const types = this.typeNode.types.map((type) => new TypeNodeResolver(type, this.current, this.parentNode, this.context).resolve());
|
|
103
97
|
return {
|
|
104
98
|
typeName: 'intersection',
|
|
105
99
|
members: types,
|
|
@@ -118,36 +112,36 @@ class TypeNodeResolver {
|
|
|
118
112
|
}
|
|
119
113
|
if (ts.isTypeLiteralNode(this.typeNode)) {
|
|
120
114
|
const properties = this.typeNode.members
|
|
121
|
-
.filter(member => ts.isPropertySignature(member))
|
|
115
|
+
.filter((member) => ts.isPropertySignature(member))
|
|
122
116
|
.reduce((res, propertySignature) => {
|
|
123
117
|
const type = new TypeNodeResolver(propertySignature.type, this.current, propertySignature, this.context).resolve();
|
|
124
118
|
const property = {
|
|
125
|
-
deprecated: (0, utils_1.isExistJSDocTag)(propertySignature, tag => tag.tagName.text === 'deprecated'),
|
|
119
|
+
deprecated: (0, utils_1.isExistJSDocTag)(propertySignature, (tag) => tag.tagName.text === 'deprecated'),
|
|
126
120
|
example: TypeNodeResolver.getNodeExample(propertySignature),
|
|
127
121
|
default: (0, utils_1.getJSDocTagComment)(propertySignature, 'default'),
|
|
128
122
|
description: this.getNodeDescription(propertySignature),
|
|
129
123
|
format: TypeNodeResolver.getNodeFormat(propertySignature),
|
|
130
124
|
name: propertySignature.name.text,
|
|
131
125
|
required: !propertySignature.questionToken,
|
|
132
|
-
type
|
|
133
|
-
validators: getPropertyValidators(propertySignature) || {}
|
|
126
|
+
type,
|
|
127
|
+
validators: getPropertyValidators(propertySignature) || {},
|
|
134
128
|
};
|
|
135
129
|
return [property, ...res];
|
|
136
130
|
}, []);
|
|
137
|
-
const indexMember = this.typeNode.members.find(member => ts.isIndexSignatureDeclaration(member));
|
|
131
|
+
const indexMember = this.typeNode.members.find((member) => ts.isIndexSignatureDeclaration(member));
|
|
138
132
|
let additionalType;
|
|
139
133
|
if (indexMember) {
|
|
140
134
|
const indexSignatureDeclaration = indexMember;
|
|
141
135
|
const indexType = new TypeNodeResolver(indexSignatureDeclaration.parameters[0].type, this.current, this.parentNode, this.context).resolve();
|
|
142
136
|
if (indexType.typeName !== 'string') {
|
|
143
|
-
throw new error_1.ResolverError(
|
|
137
|
+
throw new error_1.ResolverError('Only string indexes are supported.', this.typeNode);
|
|
144
138
|
}
|
|
145
139
|
additionalType = new TypeNodeResolver(indexSignatureDeclaration.type, this.current, this.parentNode, this.context).resolve();
|
|
146
140
|
}
|
|
147
141
|
return {
|
|
148
142
|
additionalProperties: indexMember && additionalType,
|
|
149
143
|
typeName: 'nestedObjectLiteral',
|
|
150
|
-
properties
|
|
144
|
+
properties,
|
|
151
145
|
};
|
|
152
146
|
}
|
|
153
147
|
if (this.typeNode.kind === ts.SyntaxKind.ObjectKeyword || ts.isFunctionTypeNode(this.typeNode)) {
|
|
@@ -156,25 +150,25 @@ class TypeNodeResolver {
|
|
|
156
150
|
if (ts.isMappedTypeNode(this.typeNode) && this.referencer) {
|
|
157
151
|
const type = this.current.typeChecker.getTypeFromTypeNode(this.referencer);
|
|
158
152
|
const mappedTypeNode = this.typeNode;
|
|
159
|
-
const typeChecker = this.current
|
|
153
|
+
const { typeChecker } = this.current;
|
|
160
154
|
const getDeclaration = (prop) => prop.declarations && prop.declarations[0];
|
|
161
155
|
const isIgnored = (prop) => {
|
|
162
156
|
const declaration = getDeclaration(prop);
|
|
163
|
-
return (prop.getJsDocTags().find(tag => tag.name === 'ignore') !== undefined ||
|
|
157
|
+
return (prop.getJsDocTags().find((tag) => tag.name === 'ignore') !== undefined ||
|
|
164
158
|
(declaration !== undefined && !ts.isPropertyDeclaration(declaration) && !ts.isPropertySignature(declaration) && !ts.isParameter(declaration)));
|
|
165
159
|
};
|
|
166
160
|
const properties = type
|
|
167
161
|
.getProperties()
|
|
168
162
|
// Ignore methods, getter, setter and @ignored props
|
|
169
|
-
.filter(property => isIgnored(property) === false)
|
|
163
|
+
.filter((property) => isIgnored(property) === false)
|
|
170
164
|
// Transform to property
|
|
171
|
-
.map(property => {
|
|
165
|
+
.map((property) => {
|
|
172
166
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, this.typeNode);
|
|
173
167
|
const declaration = getDeclaration(property);
|
|
174
168
|
if (declaration && ts.isPropertySignature(declaration)) {
|
|
175
169
|
return Object.assign(Object.assign({}, this.propertyFromSignature(declaration, mappedTypeNode.questionToken)), { name: property.getName() });
|
|
176
170
|
}
|
|
177
|
-
|
|
171
|
+
if (declaration && (ts.isPropertyDeclaration(declaration) || ts.isParameter(declaration))) {
|
|
178
172
|
return Object.assign(Object.assign({}, this.propertyFromDeclaration(declaration, mappedTypeNode.questionToken)), { name: property.getName() });
|
|
179
173
|
}
|
|
180
174
|
// Resolve default value, required and typeNode
|
|
@@ -189,7 +183,7 @@ class TypeNodeResolver {
|
|
|
189
183
|
// Push property
|
|
190
184
|
return {
|
|
191
185
|
name: property.getName(),
|
|
192
|
-
required
|
|
186
|
+
required,
|
|
193
187
|
deprecated: false,
|
|
194
188
|
type: new TypeNodeResolver(typeNode, this.current, this.typeNode, this.context, this.referencer).resolve(),
|
|
195
189
|
validators: {},
|
|
@@ -197,7 +191,7 @@ class TypeNodeResolver {
|
|
|
197
191
|
});
|
|
198
192
|
return {
|
|
199
193
|
typeName: 'nestedObjectLiteral',
|
|
200
|
-
properties
|
|
194
|
+
properties,
|
|
201
195
|
};
|
|
202
196
|
}
|
|
203
197
|
if (ts.isConditionalTypeNode(this.typeNode) && this.referencer && ts.isTypeReferenceNode(this.referencer)) {
|
|
@@ -213,15 +207,13 @@ class TypeNodeResolver {
|
|
|
213
207
|
// Note: I don't understand why typescript lose type for `this.referencer` (from above with isTypeReferenceNode())
|
|
214
208
|
return this.getTypeAliasReference(declaration, this.current.typeChecker.typeToString(type), this.referencer);
|
|
215
209
|
}
|
|
216
|
-
|
|
210
|
+
if (ts.isEnumDeclaration(declaration)) {
|
|
217
211
|
return this.getEnumerateType(declaration.name);
|
|
218
212
|
}
|
|
219
|
-
|
|
220
|
-
throw new error_1.ResolverError(`Couldn't resolve Conditional to TypeNode. If you think this should be resolvable, please file an Issue. We found an aliasSymbol and it's declaration was of kind ${declaration.kind}`, this.typeNode);
|
|
221
|
-
}
|
|
213
|
+
throw new error_1.ResolverError(`Couldn't resolve Conditional to TypeNode. If you think this should be resolvable, please file an Issue. We found an aliasSymbol and it's declaration was of kind ${declaration.kind}`, this.typeNode);
|
|
222
214
|
});
|
|
223
215
|
}
|
|
224
|
-
|
|
216
|
+
if (type.isClassOrInterface()) {
|
|
225
217
|
let declaration = type.symbol.declarations[0];
|
|
226
218
|
if (declaration.name) {
|
|
227
219
|
declaration = this.getModelTypeDeclaration(declaration.name);
|
|
@@ -229,13 +221,11 @@ class TypeNodeResolver {
|
|
|
229
221
|
const name = TypeNodeResolver.getRefTypeName(this.referencer.getText());
|
|
230
222
|
return this.handleCachingAndCircularReferences(name, () => this.getModelReference(declaration, this.current.typeChecker.typeToString(type)));
|
|
231
223
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
throw new error_1.ResolverError(`Couldn't resolve Conditional to TypeNode. If you think this should be resolvable, please file an Issue. The flags on the result of the ConditionalType was ${type.flags}`, this.typeNode);
|
|
238
|
-
}
|
|
224
|
+
try {
|
|
225
|
+
return new TypeNodeResolver(this.current.typeChecker.typeToTypeNode(type, undefined, ts.NodeBuilderFlags.NoTruncation), this.current, this.typeNode, this.context, this.referencer).resolve();
|
|
226
|
+
}
|
|
227
|
+
catch (_a) {
|
|
228
|
+
throw new error_1.ResolverError(`Couldn't resolve Conditional to TypeNode. If you think this should be resolvable, please file an Issue. The flags on the result of the ConditionalType was ${type.flags}`, this.typeNode);
|
|
239
229
|
}
|
|
240
230
|
}
|
|
241
231
|
if (ts.isTypeOperatorNode(this.typeNode) && this.typeNode.operator === ts.SyntaxKind.KeyOfKeyword) {
|
|
@@ -279,15 +269,13 @@ class TypeNodeResolver {
|
|
|
279
269
|
// @ts-ignore
|
|
280
270
|
if (this.typeNode.kind === ts.SyntaxKind.TemplateLiteralType) {
|
|
281
271
|
const type = this.current.typeChecker.getTypeFromTypeNode(this.referencer || this.typeNode);
|
|
282
|
-
if (type.isUnion() && type.types.every(unionElementType => unionElementType.isStringLiteral())) {
|
|
272
|
+
if (type.isUnion() && type.types.every((unionElementType) => unionElementType.isStringLiteral())) {
|
|
283
273
|
return {
|
|
284
274
|
typeName: 'enum',
|
|
285
275
|
members: type.types.map((stringLiteralType) => stringLiteralType.value),
|
|
286
276
|
};
|
|
287
277
|
}
|
|
288
|
-
|
|
289
|
-
throw new error_1.ResolverError(`Could not the type of ${this.current.typeChecker.typeToString(this.current.typeChecker.getTypeFromTypeNode(this.typeNode), this.typeNode)}`, this.typeNode);
|
|
290
|
-
}
|
|
278
|
+
throw new error_1.ResolverError(`Could not the type of ${this.current.typeChecker.typeToString(this.current.typeChecker.getTypeFromTypeNode(this.typeNode), this.typeNode)}`, this.typeNode);
|
|
291
279
|
}
|
|
292
280
|
if (ts.isParenthesizedTypeNode(this.typeNode)) {
|
|
293
281
|
return new TypeNodeResolver(this.typeNode.type, this.current, this.typeNode, this.context, this.referencer).resolve();
|
|
@@ -346,19 +334,19 @@ class TypeNodeResolver {
|
|
|
346
334
|
}
|
|
347
335
|
static getUtilityTypeOptions(typeArguments) {
|
|
348
336
|
const utilityOptions = {
|
|
349
|
-
keys: []
|
|
337
|
+
keys: [],
|
|
350
338
|
};
|
|
351
339
|
if (typeArguments.length >= 2) {
|
|
352
340
|
if (ts.isUnionTypeNode(typeArguments[1])) {
|
|
353
341
|
const args = typeArguments[1].types;
|
|
354
342
|
for (let i = 0; i < args.length; i++) {
|
|
355
343
|
if (ts.isLiteralTypeNode(args[i])) {
|
|
356
|
-
utilityOptions
|
|
344
|
+
utilityOptions.keys.push(TypeNodeResolver.getLiteralValue(args[i]));
|
|
357
345
|
}
|
|
358
346
|
}
|
|
359
347
|
}
|
|
360
348
|
if (ts.isLiteralTypeNode(typeArguments[1])) {
|
|
361
|
-
utilityOptions
|
|
349
|
+
utilityOptions.keys.push(TypeNodeResolver.getLiteralValue(typeArguments[1]));
|
|
362
350
|
}
|
|
363
351
|
}
|
|
364
352
|
return utilityOptions;
|
|
@@ -368,7 +356,7 @@ class TypeNodeResolver {
|
|
|
368
356
|
return properties;
|
|
369
357
|
}
|
|
370
358
|
return properties
|
|
371
|
-
.filter(property => {
|
|
359
|
+
.filter((property) => {
|
|
372
360
|
const name = typeof property.name !== 'string' ? property.name.text : property.name;
|
|
373
361
|
switch (utilityType) {
|
|
374
362
|
case 'Pick':
|
|
@@ -378,7 +366,7 @@ class TypeNodeResolver {
|
|
|
378
366
|
}
|
|
379
367
|
return true;
|
|
380
368
|
})
|
|
381
|
-
.map(property => {
|
|
369
|
+
.map((property) => {
|
|
382
370
|
if ((0, metadata_utils_1.hasOwnProperty)(property, 'required')) {
|
|
383
371
|
switch (utilityType) {
|
|
384
372
|
case 'Partial':
|
|
@@ -446,21 +434,19 @@ class TypeNodeResolver {
|
|
|
446
434
|
return { typeName: 'double' };
|
|
447
435
|
}
|
|
448
436
|
const tags = (0, utils_1.getJSDocTagNames)(parentNode)
|
|
449
|
-
.filter(name =>
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
.map(name => name.toLowerCase());
|
|
458
|
-
const data = (0, decorator_1.getNodeDecorators)(parentNode, identifier => [
|
|
437
|
+
.filter((name) => [
|
|
438
|
+
'isInt',
|
|
439
|
+
'isLong',
|
|
440
|
+
'isFloat',
|
|
441
|
+
'isDouble',
|
|
442
|
+
].some((m) => m.toLowerCase() === name.toLowerCase()))
|
|
443
|
+
.map((name) => name.toLowerCase());
|
|
444
|
+
const data = (0, decorator_1.getNodeDecorators)(parentNode, (identifier) => [
|
|
459
445
|
'isInt',
|
|
460
446
|
'isLong',
|
|
461
447
|
'isFloat',
|
|
462
|
-
'isDouble'
|
|
463
|
-
].some(m => m.toLowerCase() === identifier.text.toLowerCase()));
|
|
448
|
+
'isDouble',
|
|
449
|
+
].some((m) => m.toLowerCase() === identifier.text.toLowerCase()));
|
|
464
450
|
let decorator = data.length > 0 ? data[0].text : undefined;
|
|
465
451
|
if (typeof decorator !== 'undefined') {
|
|
466
452
|
decorator = decorator.toLowerCase();
|
|
@@ -505,9 +491,7 @@ class TypeNodeResolver {
|
|
|
505
491
|
if (!parentNode) {
|
|
506
492
|
return { typeName: 'datetime' };
|
|
507
493
|
}
|
|
508
|
-
const tags = (0, utils_1.getJSDocTagNames)(parentNode).filter(name =>
|
|
509
|
-
return ['isDate', 'isDateTime'].some(m => m === name);
|
|
510
|
-
});
|
|
494
|
+
const tags = (0, utils_1.getJSDocTagNames)(parentNode).filter((name) => ['isDate', 'isDateTime'].some((m) => m === name));
|
|
511
495
|
if (tags.length === 0) {
|
|
512
496
|
return { typeName: 'datetime' };
|
|
513
497
|
}
|
|
@@ -525,7 +509,7 @@ class TypeNodeResolver {
|
|
|
525
509
|
}
|
|
526
510
|
getEnumerateType(typeName) {
|
|
527
511
|
const enumName = typeName.text;
|
|
528
|
-
let enumNodes = this.current.nodes.filter(node => node.kind === ts.SyntaxKind.EnumDeclaration).filter(node => node.name.text === enumName);
|
|
512
|
+
let enumNodes = this.current.nodes.filter((node) => node.kind === ts.SyntaxKind.EnumDeclaration).filter((node) => node.name.text === enumName);
|
|
529
513
|
if (!enumNodes.length) {
|
|
530
514
|
return undefined;
|
|
531
515
|
}
|
|
@@ -534,18 +518,16 @@ class TypeNodeResolver {
|
|
|
534
518
|
throw new error_1.ResolverError(`Multiple matching enum found for enum ${enumName}; please make enum names unique.`);
|
|
535
519
|
}
|
|
536
520
|
const enumDeclaration = enumNodes[0];
|
|
537
|
-
const isNotUndefined = (item) =>
|
|
538
|
-
return item !== undefined;
|
|
539
|
-
};
|
|
521
|
+
const isNotUndefined = (item) => item !== undefined;
|
|
540
522
|
const enums = enumDeclaration.members.map(this.current.typeChecker.getConstantValue.bind(this.current.typeChecker)).filter(isNotUndefined);
|
|
541
|
-
const enumNames = enumDeclaration.members.map(e => e.name.getText()).filter(isNotUndefined);
|
|
523
|
+
const enumNames = enumDeclaration.members.map((e) => e.name.getText()).filter(isNotUndefined);
|
|
542
524
|
return {
|
|
543
525
|
typeName: 'refEnum',
|
|
544
526
|
description: this.getNodeDescription(enumDeclaration),
|
|
545
527
|
members: enums,
|
|
546
528
|
memberNames: enumNames,
|
|
547
529
|
refName: enumName,
|
|
548
|
-
deprecated: (0, utils_1.isExistJSDocTag)(enumDeclaration, tag => tag.tagName.text === 'deprecated')
|
|
530
|
+
deprecated: (0, utils_1.isExistJSDocTag)(enumDeclaration, (tag) => tag.tagName.text === 'deprecated'),
|
|
549
531
|
};
|
|
550
532
|
}
|
|
551
533
|
getReferenceType(node) {
|
|
@@ -557,14 +539,14 @@ class TypeNodeResolver {
|
|
|
557
539
|
type = node.expression;
|
|
558
540
|
}
|
|
559
541
|
else {
|
|
560
|
-
throw new error_1.ResolverError(
|
|
542
|
+
throw new error_1.ResolverError('Can\'t resolve Reference type.');
|
|
561
543
|
}
|
|
562
544
|
// Can't invoke getText on Synthetic Nodes
|
|
563
545
|
let resolvableName = node.pos !== -1 ? node.getText() : type.text;
|
|
564
546
|
if (node.pos === -1 && 'typeArguments' in node && Array.isArray(node.typeArguments)) {
|
|
565
547
|
// Add typeArguments for Synthetic nodes (e.g. Record<> in TestClassModel.indexedResponse)
|
|
566
548
|
const argumentsString = node.typeArguments
|
|
567
|
-
.map(arg => {
|
|
549
|
+
.map((arg) => {
|
|
568
550
|
if (ts.isLiteralTypeNode(arg)) {
|
|
569
551
|
return `'${String(TypeNodeResolver.getLiteralValue(arg))}'`;
|
|
570
552
|
}
|
|
@@ -582,10 +564,10 @@ class TypeNodeResolver {
|
|
|
582
564
|
const utilityTypeSupported = TypeNodeResolver.isSupportedUtilityType(identifierName);
|
|
583
565
|
const utilityType = utilityTypeSupported ? identifierName : undefined;
|
|
584
566
|
let utilityOptions = {
|
|
585
|
-
keys: []
|
|
567
|
+
keys: [],
|
|
586
568
|
};
|
|
587
569
|
if (utilityTypeSupported) {
|
|
588
|
-
const typeArguments = type.parent
|
|
570
|
+
const { typeArguments } = type.parent;
|
|
589
571
|
if (ts.isTypeReferenceNode(typeArguments[0])) {
|
|
590
572
|
type = typeArguments[0].typeName;
|
|
591
573
|
}
|
|
@@ -593,7 +575,7 @@ class TypeNodeResolver {
|
|
|
593
575
|
type = typeArguments[0].expression;
|
|
594
576
|
}
|
|
595
577
|
else {
|
|
596
|
-
throw new error_1.ResolverError(
|
|
578
|
+
throw new error_1.ResolverError('Can\'t resolve Reference type.');
|
|
597
579
|
}
|
|
598
580
|
utilityOptions = TypeNodeResolver.getUtilityTypeOptions(typeArguments);
|
|
599
581
|
}
|
|
@@ -626,7 +608,7 @@ class TypeNodeResolver {
|
|
|
626
608
|
members: [this.current.typeChecker.getConstantValue(declaration)],
|
|
627
609
|
// @ts-ignore
|
|
628
610
|
memberNames: [declaration.name.getText()],
|
|
629
|
-
deprecated: (0, utils_1.isExistJSDocTag)(declaration, tag => tag.tagName.text === 'deprecated')
|
|
611
|
+
deprecated: (0, utils_1.isExistJSDocTag)(declaration, (tag) => tag.tagName.text === 'deprecated'),
|
|
630
612
|
};
|
|
631
613
|
}
|
|
632
614
|
else {
|
|
@@ -654,15 +636,15 @@ class TypeNodeResolver {
|
|
|
654
636
|
type = new TypeNodeResolver(declaration.type, this.current, declaration, this.context, this.referencer || referencer).resolve();
|
|
655
637
|
}
|
|
656
638
|
const example = TypeNodeResolver.getNodeExample(declaration);
|
|
657
|
-
return Object.assign({ typeName: 'refAlias', default: (0, utils_1.getJSDocTagComment)(declaration, 'default'), description: this.getNodeDescription(declaration), refName
|
|
639
|
+
return Object.assign({ typeName: 'refAlias', default: (0, utils_1.getJSDocTagComment)(declaration, 'default'), description: this.getNodeDescription(declaration), refName, format: TypeNodeResolver.getNodeFormat(declaration), type, validators: getPropertyValidators(declaration) || {}, deprecated: (0, utils_1.isExistJSDocTag)(declaration, (tag) => tag.tagName.text === 'deprecated') }, (example && { example }));
|
|
658
640
|
}
|
|
659
641
|
getModelReference(modelType, name, utilityType, utilityOptions) {
|
|
660
642
|
const example = TypeNodeResolver.getNodeExample(modelType);
|
|
661
643
|
const description = this.getNodeDescription(modelType);
|
|
662
|
-
const deprecated = (0, utils_1.isExistJSDocTag)(modelType, tag => tag.tagName.text === 'deprecated') || typeof this.current.decoratorMapper.match('DEPRECATED', modelType) !== 'undefined';
|
|
644
|
+
const deprecated = (0, utils_1.isExistJSDocTag)(modelType, (tag) => tag.tagName.text === 'deprecated') || typeof this.current.decoratorMapper.match('DEPRECATED', modelType) !== 'undefined';
|
|
663
645
|
// Handle toJSON methods
|
|
664
646
|
if (!modelType.name) {
|
|
665
|
-
throw new error_1.ResolverError(
|
|
647
|
+
throw new error_1.ResolverError('Can\'t get Symbol from anonymous class', modelType);
|
|
666
648
|
}
|
|
667
649
|
const type = this.current.typeChecker.getTypeAtLocation(modelType.name);
|
|
668
650
|
const toJSON = this.current.typeChecker.getPropertyOfType(type, 'toJSON');
|
|
@@ -673,12 +655,12 @@ class TypeNodeResolver {
|
|
|
673
655
|
const implicitType = this.current.typeChecker.getReturnTypeOfSignature(signature);
|
|
674
656
|
nodeType = this.current.typeChecker.typeToTypeNode(implicitType, undefined, ts.NodeBuilderFlags.NoTruncation);
|
|
675
657
|
}
|
|
676
|
-
return Object.assign({ refName: TypeNodeResolver.getRefTypeName(name, utilityType)
|
|
658
|
+
return Object.assign({ refName: `${TypeNodeResolver.getRefTypeName(name, utilityType)}Alias`, typeName: 'refAlias', description, type: new TypeNodeResolver(nodeType, this.current).resolve(), deprecated, validators: {} }, (example && { example }));
|
|
677
659
|
}
|
|
678
660
|
const properties = this.getModelProperties(modelType, undefined, utilityType, utilityOptions);
|
|
679
661
|
const additionalProperties = this.getModelAdditionalProperties(modelType);
|
|
680
662
|
const inheritedProperties = this.getModelInheritedProperties(modelType) || [];
|
|
681
|
-
const referenceType = Object.assign({ additionalProperties
|
|
663
|
+
const referenceType = Object.assign({ additionalProperties, typeName: 'refObject', description, properties: this.filterUtilityProperties(inheritedProperties, utilityType, utilityOptions), refName: TypeNodeResolver.getRefTypeName(name, utilityType), deprecated }, (example && { example }));
|
|
682
664
|
referenceType.properties = referenceType.properties.concat(properties);
|
|
683
665
|
return referenceType;
|
|
684
666
|
}
|
|
@@ -700,13 +682,11 @@ class TypeNodeResolver {
|
|
|
700
682
|
.replace(/-/g, ''));
|
|
701
683
|
}
|
|
702
684
|
contextualizedName(name) {
|
|
703
|
-
return Object.entries(this.context).reduce((acc, [key, entry]) =>
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
.replace(new RegExp(`<\\s*([^<]*\\s)*\\s*(${key})(\\s[^<]*)*\\s*<`, 'g'), `<$1${entry.getText()}$3<`);
|
|
709
|
-
}, name);
|
|
685
|
+
return Object.entries(this.context).reduce((acc, [key, entry]) => acc
|
|
686
|
+
.replace(new RegExp(`<\\s*([^>]*\\s)*\\s*(${key})(\\s[^>]*)*\\s*>`, 'g'), `<$1${entry.getText()}$3>`)
|
|
687
|
+
.replace(new RegExp(`<\\s*([^,]*\\s)*\\s*(${key})(\\s[^,]*)*\\s*,`, 'g'), `<$1${entry.getText()}$3,`)
|
|
688
|
+
.replace(new RegExp(`,\\s*([^>]*\\s)*\\s*(${key})(\\s[^>]*)*\\s*>`, 'g'), `,$1${entry.getText()}$3>`)
|
|
689
|
+
.replace(new RegExp(`<\\s*([^<]*\\s)*\\s*(${key})(\\s[^<]*)*\\s*<`, 'g'), `<$1${entry.getText()}$3<`), name);
|
|
710
690
|
}
|
|
711
691
|
handleCachingAndCircularReferences(name, declarationResolver) {
|
|
712
692
|
try {
|
|
@@ -732,9 +712,9 @@ class TypeNodeResolver {
|
|
|
732
712
|
createCircularDependencyResolver(refName) {
|
|
733
713
|
const referenceType = {
|
|
734
714
|
typeName: 'refObject',
|
|
735
|
-
refName
|
|
715
|
+
refName,
|
|
736
716
|
};
|
|
737
|
-
this.current.registerDependencyResolver(referenceTypes => {
|
|
717
|
+
this.current.registerDependencyResolver((referenceTypes) => {
|
|
738
718
|
const realReferenceType = referenceTypes[refName];
|
|
739
719
|
if (!realReferenceType) {
|
|
740
720
|
return;
|
|
@@ -788,16 +768,14 @@ class TypeNodeResolver {
|
|
|
788
768
|
const leftmostName = leftmost.kind === ts.SyntaxKind.Identifier ? leftmost.text : leftmost.right.text;
|
|
789
769
|
const moduleDeclarations = this.findMatchingModuleOrEnumDeclaration(statements, leftmostName);
|
|
790
770
|
if (moduleDeclarations.length > 0) {
|
|
791
|
-
statements = Array.prototype.concat(...moduleDeclarations.map(declaration => {
|
|
771
|
+
statements = Array.prototype.concat(...moduleDeclarations.map((declaration) => {
|
|
792
772
|
if (ts.isEnumDeclaration(declaration)) {
|
|
793
773
|
return declaration.members;
|
|
794
774
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
throw new error_1.ResolverError(`Module declaration found for ${leftmostName} has no body.`);
|
|
798
|
-
}
|
|
799
|
-
return declaration.body.statements;
|
|
775
|
+
if (!declaration.body || !ts.isModuleBlock(declaration.body)) {
|
|
776
|
+
throw new error_1.ResolverError(`Module declaration found for ${leftmostName} has no body.`);
|
|
800
777
|
}
|
|
778
|
+
return declaration.body.statements;
|
|
801
779
|
}));
|
|
802
780
|
}
|
|
803
781
|
leftmost = leftmost.parent;
|
|
@@ -808,7 +786,7 @@ class TypeNodeResolver {
|
|
|
808
786
|
const leftmostIdentifier = TypeNodeResolver.resolveLeftmostIdentifier(type);
|
|
809
787
|
const statements = this.resolveModelTypeScope(leftmostIdentifier, this.current.nodes);
|
|
810
788
|
const typeName = type.kind === ts.SyntaxKind.Identifier ? type.text : type.right.text;
|
|
811
|
-
let modelTypes = statements.filter(node => {
|
|
789
|
+
let modelTypes = statements.filter((node) => {
|
|
812
790
|
var _a;
|
|
813
791
|
if (!TypeNodeResolver.nodeIsUsable(node) || !this.current.isExportedNode(node)) {
|
|
814
792
|
return false;
|
|
@@ -821,43 +799,39 @@ class TypeNodeResolver {
|
|
|
821
799
|
}
|
|
822
800
|
if (modelTypes.length > 1) {
|
|
823
801
|
// remove types that are from typescript e.g. 'Account'
|
|
824
|
-
modelTypes = modelTypes.filter(modelType =>
|
|
825
|
-
return modelType.getSourceFile().fileName.replace(/\\/g, '/').toLowerCase().indexOf('node_modules') <= -1;
|
|
826
|
-
});
|
|
802
|
+
modelTypes = modelTypes.filter((modelType) => modelType.getSourceFile().fileName.replace(/\\/g, '/').toLowerCase().indexOf('node_modules') <= -1);
|
|
827
803
|
modelTypes = TypeNodeResolver.getDesignatedModels(modelTypes, typeName);
|
|
828
804
|
}
|
|
829
805
|
if (modelTypes.length > 1) {
|
|
830
|
-
const conflicts = modelTypes.map(modelType => modelType.getSourceFile().fileName).join('"; "');
|
|
806
|
+
const conflicts = modelTypes.map((modelType) => modelType.getSourceFile().fileName).join('"; "');
|
|
831
807
|
throw new error_1.ResolverError(`Multiple matching models found for referenced type ${typeName}; please make model names unique. Conflicts found: "${conflicts}".`);
|
|
832
808
|
}
|
|
833
809
|
return modelTypes[0];
|
|
834
810
|
}
|
|
835
811
|
getModelProperties(node, overrideToken, utilityType, utilityOptions) {
|
|
836
|
-
const isIgnored = (e) =>
|
|
837
|
-
return (0, utils_1.isExistJSDocTag)(e, tag => tag.tagName.text === 'ignore');
|
|
838
|
-
};
|
|
812
|
+
const isIgnored = (e) => (0, utils_1.isExistJSDocTag)(e, (tag) => tag.tagName.text === 'ignore');
|
|
839
813
|
// Interface model
|
|
840
814
|
if (ts.isInterfaceDeclaration(node)) {
|
|
841
|
-
return node.members.filter(member => !isIgnored(member) && ts.isPropertySignature(member)).map((member) => this.propertyFromSignature(member, overrideToken));
|
|
815
|
+
return node.members.filter((member) => !isIgnored(member) && ts.isPropertySignature(member)).map((member) => this.propertyFromSignature(member, overrideToken));
|
|
842
816
|
}
|
|
843
817
|
// Class model
|
|
844
818
|
let properties = node.members
|
|
845
|
-
.filter(member => !isIgnored(member))
|
|
846
|
-
.filter(member => member.kind === ts.SyntaxKind.PropertyDeclaration)
|
|
847
|
-
.filter(member => !this.hasStaticModifier(member))
|
|
848
|
-
.filter(member => this.hasPublicModifier(member));
|
|
849
|
-
const classConstructor = node.members.find(member => ts.isConstructorDeclaration(member));
|
|
819
|
+
.filter((member) => !isIgnored(member))
|
|
820
|
+
.filter((member) => member.kind === ts.SyntaxKind.PropertyDeclaration)
|
|
821
|
+
.filter((member) => !this.hasStaticModifier(member))
|
|
822
|
+
.filter((member) => this.hasPublicModifier(member));
|
|
823
|
+
const classConstructor = node.members.find((member) => ts.isConstructorDeclaration(member));
|
|
850
824
|
if (classConstructor && classConstructor.parameters) {
|
|
851
|
-
const constructorProperties = classConstructor.parameters.filter(parameter => this.isAccessibleParameter(parameter));
|
|
825
|
+
const constructorProperties = classConstructor.parameters.filter((parameter) => this.isAccessibleParameter(parameter));
|
|
852
826
|
properties.push(...constructorProperties);
|
|
853
827
|
}
|
|
854
828
|
properties = this.filterUtilityProperties(properties, utilityType, utilityOptions);
|
|
855
|
-
return properties.map(property => this.propertyFromDeclaration(property, overrideToken, utilityType));
|
|
829
|
+
return properties.map((property) => this.propertyFromDeclaration(property, overrideToken, utilityType));
|
|
856
830
|
}
|
|
857
831
|
propertyFromSignature(propertySignature, overrideToken) {
|
|
858
832
|
const identifier = propertySignature.name;
|
|
859
833
|
if (!propertySignature.type) {
|
|
860
|
-
throw new error_1.ResolverError(
|
|
834
|
+
throw new error_1.ResolverError('No valid type found for property declaration.');
|
|
861
835
|
}
|
|
862
836
|
let required = !propertySignature.questionToken;
|
|
863
837
|
if (overrideToken && overrideToken.kind === ts.SyntaxKind.MinusToken) {
|
|
@@ -867,15 +841,15 @@ class TypeNodeResolver {
|
|
|
867
841
|
required = false;
|
|
868
842
|
}
|
|
869
843
|
const property = {
|
|
870
|
-
deprecated: (0, utils_1.isExistJSDocTag)(propertySignature, tag => tag.tagName.text === 'deprecated'),
|
|
844
|
+
deprecated: (0, utils_1.isExistJSDocTag)(propertySignature, (tag) => tag.tagName.text === 'deprecated'),
|
|
871
845
|
default: (0, utils_1.getJSDocTagComment)(propertySignature, 'default'),
|
|
872
846
|
description: this.getNodeDescription(propertySignature),
|
|
873
847
|
example: TypeNodeResolver.getNodeExample(propertySignature),
|
|
874
848
|
format: TypeNodeResolver.getNodeFormat(propertySignature),
|
|
875
849
|
name: identifier.text,
|
|
876
|
-
required
|
|
850
|
+
required,
|
|
877
851
|
type: new TypeNodeResolver(propertySignature.type, this.current, propertySignature.type.parent, this.context, propertySignature.type).resolve(),
|
|
878
|
-
validators: getPropertyValidators(propertySignature) || {}
|
|
852
|
+
validators: getPropertyValidators(propertySignature) || {},
|
|
879
853
|
};
|
|
880
854
|
return property;
|
|
881
855
|
}
|
|
@@ -887,7 +861,7 @@ class TypeNodeResolver {
|
|
|
887
861
|
typeNode = this.current.typeChecker.typeToTypeNode(tsType, undefined, ts.NodeBuilderFlags.NoTruncation);
|
|
888
862
|
}
|
|
889
863
|
if (!typeNode) {
|
|
890
|
-
throw new error_1.ResolverError(
|
|
864
|
+
throw new error_1.ResolverError('No valid type found for property declaration.');
|
|
891
865
|
}
|
|
892
866
|
const type = new TypeNodeResolver(typeNode, this.current, propertyDeclaration, this.context, typeNode).resolve();
|
|
893
867
|
let required = !propertyDeclaration.questionToken && !propertyDeclaration.initializer;
|
|
@@ -906,28 +880,28 @@ class TypeNodeResolver {
|
|
|
906
880
|
}
|
|
907
881
|
}
|
|
908
882
|
const property = {
|
|
909
|
-
deprecated: (0, utils_1.isExistJSDocTag)(propertyDeclaration, tag => tag.tagName.text === 'deprecated'),
|
|
883
|
+
deprecated: (0, utils_1.isExistJSDocTag)(propertyDeclaration, (tag) => tag.tagName.text === 'deprecated'),
|
|
910
884
|
default: (0, utils_2.getInitializerValue)(propertyDeclaration.initializer, this.current.typeChecker),
|
|
911
885
|
description: this.getNodeDescription(propertyDeclaration),
|
|
912
886
|
example: TypeNodeResolver.getNodeExample(propertyDeclaration),
|
|
913
887
|
format: TypeNodeResolver.getNodeFormat(propertyDeclaration),
|
|
914
888
|
name: identifier.text,
|
|
915
|
-
required
|
|
916
|
-
type
|
|
889
|
+
required,
|
|
890
|
+
type,
|
|
917
891
|
validators: getPropertyValidators(propertyDeclaration) || {},
|
|
918
892
|
};
|
|
919
893
|
return property;
|
|
920
894
|
}
|
|
921
895
|
getModelAdditionalProperties(node) {
|
|
922
896
|
if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {
|
|
923
|
-
const indexMember = node.members.find(member => member.kind === ts.SyntaxKind.IndexSignature);
|
|
897
|
+
const indexMember = node.members.find((member) => member.kind === ts.SyntaxKind.IndexSignature);
|
|
924
898
|
if (!indexMember) {
|
|
925
899
|
return undefined;
|
|
926
900
|
}
|
|
927
901
|
const indexSignatureDeclaration = indexMember;
|
|
928
902
|
const indexType = new TypeNodeResolver(indexSignatureDeclaration.parameters[0].type, this.current, this.parentNode, this.context).resolve();
|
|
929
903
|
if (indexType.typeName !== 'string') {
|
|
930
|
-
throw new error_1.ResolverError(
|
|
904
|
+
throw new error_1.ResolverError('Only string indexers are supported.', this.typeNode);
|
|
931
905
|
}
|
|
932
906
|
return new TypeNodeResolver(indexSignatureDeclaration.type, this.current, this.parentNode, this.context).resolve();
|
|
933
907
|
}
|
|
@@ -962,15 +936,15 @@ class TypeNodeResolver {
|
|
|
962
936
|
}
|
|
963
937
|
getModelInheritedProperties(modelTypeDeclaration) {
|
|
964
938
|
let properties = [];
|
|
965
|
-
const heritageClauses = modelTypeDeclaration
|
|
939
|
+
const { heritageClauses } = modelTypeDeclaration;
|
|
966
940
|
if (!heritageClauses) {
|
|
967
941
|
return properties;
|
|
968
942
|
}
|
|
969
|
-
heritageClauses.forEach(clause => {
|
|
943
|
+
heritageClauses.forEach((clause) => {
|
|
970
944
|
if (!clause.types) {
|
|
971
945
|
return;
|
|
972
946
|
}
|
|
973
|
-
clause.types.forEach(t => {
|
|
947
|
+
clause.types.forEach((t) => {
|
|
974
948
|
const baseEntityName = t.expression;
|
|
975
949
|
// create subContext
|
|
976
950
|
const resetCtx = this.typeArgumentsToContext(t, baseEntityName, this.context);
|
|
@@ -992,7 +966,7 @@ class TypeNodeResolver {
|
|
|
992
966
|
}
|
|
993
967
|
}
|
|
994
968
|
else if (referenceType.typeName === 'refObject') {
|
|
995
|
-
referenceType.properties.forEach(property => properties.push(property));
|
|
969
|
+
referenceType.properties.forEach((property) => properties.push(property));
|
|
996
970
|
}
|
|
997
971
|
else {
|
|
998
972
|
// todo: should never assert
|
|
@@ -1006,15 +980,11 @@ class TypeNodeResolver {
|
|
|
1006
980
|
}
|
|
1007
981
|
hasPublicModifier(node) {
|
|
1008
982
|
return (!node.modifiers ||
|
|
1009
|
-
node.modifiers.every(modifier =>
|
|
1010
|
-
return modifier.kind !== ts.SyntaxKind.ProtectedKeyword && modifier.kind !== ts.SyntaxKind.PrivateKeyword;
|
|
1011
|
-
}));
|
|
983
|
+
node.modifiers.every((modifier) => modifier.kind !== ts.SyntaxKind.ProtectedKeyword && modifier.kind !== ts.SyntaxKind.PrivateKeyword));
|
|
1012
984
|
}
|
|
1013
985
|
hasStaticModifier(node) {
|
|
1014
986
|
return (node.modifiers &&
|
|
1015
|
-
node.modifiers.some(modifier =>
|
|
1016
|
-
return modifier.kind === ts.SyntaxKind.StaticKeyword;
|
|
1017
|
-
}));
|
|
987
|
+
node.modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword));
|
|
1018
988
|
}
|
|
1019
989
|
isAccessibleParameter(node) {
|
|
1020
990
|
// No modifiers
|
|
@@ -1022,14 +992,12 @@ class TypeNodeResolver {
|
|
|
1022
992
|
return false;
|
|
1023
993
|
}
|
|
1024
994
|
// public || public readonly
|
|
1025
|
-
if (node.modifiers.some(modifier => modifier.kind === ts.SyntaxKind.PublicKeyword)) {
|
|
995
|
+
if (node.modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.PublicKeyword)) {
|
|
1026
996
|
return true;
|
|
1027
997
|
}
|
|
1028
998
|
// readonly, not private readonly, not public readonly
|
|
1029
|
-
const isReadonly = node.modifiers.some(modifier => modifier.kind === ts.SyntaxKind.ReadonlyKeyword);
|
|
1030
|
-
const isProtectedOrPrivate = node.modifiers.some(modifier =>
|
|
1031
|
-
return modifier.kind === ts.SyntaxKind.ProtectedKeyword || modifier.kind === ts.SyntaxKind.PrivateKeyword;
|
|
1032
|
-
});
|
|
999
|
+
const isReadonly = node.modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.ReadonlyKeyword);
|
|
1000
|
+
const isProtectedOrPrivate = node.modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.ProtectedKeyword || modifier.kind === ts.SyntaxKind.PrivateKeyword);
|
|
1033
1001
|
return isReadonly && !isProtectedOrPrivate;
|
|
1034
1002
|
}
|
|
1035
1003
|
getNodeDescription(node) {
|