Skip to content

Commit

Permalink
nOL: Don't cast
Browse files Browse the repository at this point in the history
  • Loading branch information
WoH committed Sep 1, 2019
1 parent d9a9367 commit 1ea71ce
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/metadataGeneration/typeResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,17 @@ export class TypeResolver {
.filter(member => ts.isPropertySignature(member))
.reduce((res, propertySignature: ts.PropertySignature) => {
const type = new TypeResolver(propertySignature.type as ts.TypeNode, this.current, propertySignature).resolve();

return [
{
default: getJSDocComment(propertySignature, 'default'),
description: this.getNodeDescription(propertySignature),
format: this.getNodeFormat(propertySignature),
name: (propertySignature.name as ts.Identifier).text,
required: !propertySignature.questionToken,
type,
validators: getPropertyValidators(propertySignature),
} as Tsoa.Property,
...res,
];
const property: Tsoa.Property = {
default: getJSDocComment(propertySignature, 'default'),
description: this.getNodeDescription(propertySignature),
format: this.getNodeFormat(propertySignature),
name: (propertySignature.name as ts.Identifier).text,
required: !propertySignature.questionToken,
type,
validators: getPropertyValidators(propertySignature) || {},
};

return [property, ...res];
}, []);

const indexMember = this.typeNode.members.find(member => ts.isIndexSignatureDeclaration(member));
Expand All @@ -122,11 +120,12 @@ export class TypeResolver {
additionalType = new TypeResolver(indexSignatureDeclaration.type as ts.TypeNode, this.current).resolve();
}

return {
const objLiteral: Tsoa.ObjectLiteralType = {
additionalProperties: indexMember && additionalType,
dataType: 'nestedObjectLiteral',
properties,
} as Tsoa.ObjectLiteralType;
};
return objLiteral;
}

if (this.typeNode.kind === ts.SyntaxKind.ObjectKeyword) {
Expand Down

0 comments on commit 1ea71ce

Please sign in to comment.