@@ -109,25 +109,23 @@ export class TypeResolver {
109
109
}
110
110
111
111
if ( ts . isTypeLiteralNode ( this . typeNode ) ) {
112
- const properties = this . typeNode . members
113
- . filter ( member => ts . isPropertySignature ( member ) )
114
- . reduce ( ( res , propertySignature : ts . PropertySignature ) => {
115
- const type = new TypeResolver ( propertySignature . type as ts . TypeNode , this . current , propertySignature , this . context ) . resolve ( ) ;
116
- const property : Tsoa . Property = {
117
- example : this . getNodeExample ( propertySignature ) ,
118
- default : getJSDocComment ( propertySignature , 'default' ) ,
119
- description : this . getNodeDescription ( propertySignature ) ,
120
- format : this . getNodeFormat ( propertySignature ) ,
121
- name : ( propertySignature . name as ts . Identifier ) . text ,
122
- required : ! propertySignature . questionToken ,
123
- type,
124
- validators : getPropertyValidators ( propertySignature ) || { } ,
125
- deprecated : isExistJSDocTag ( propertySignature , tag => tag . tagName . text === 'deprecated' ) ,
126
- extensions : this . getNodeExtension ( propertySignature ) ,
127
- } ;
112
+ const properties = this . typeNode . members . filter ( ts . isPropertySignature ) . reduce < Tsoa . Property [ ] > ( ( res , propertySignature : ts . PropertySignature ) => {
113
+ const type = new TypeResolver ( propertySignature . type as ts . TypeNode , this . current , propertySignature , this . context ) . resolve ( ) ;
114
+ const property : Tsoa . Property = {
115
+ example : this . getNodeExample ( propertySignature ) ,
116
+ default : getJSDocComment ( propertySignature , 'default' ) ,
117
+ description : this . getNodeDescription ( propertySignature ) ,
118
+ format : this . getNodeFormat ( propertySignature ) ,
119
+ name : ( propertySignature . name as ts . Identifier ) . text ,
120
+ required : ! propertySignature . questionToken ,
121
+ type,
122
+ validators : getPropertyValidators ( propertySignature ) || { } ,
123
+ deprecated : isExistJSDocTag ( propertySignature , tag => tag . tagName . text === 'deprecated' ) ,
124
+ extensions : this . getNodeExtension ( propertySignature ) ,
125
+ } ;
128
126
129
- return [ property , ...res ] ;
130
- } , [ ] ) ;
127
+ return [ property , ...res ] ;
128
+ } , [ ] ) ;
131
129
132
130
const indexMember = this . typeNode . members . find ( member => ts . isIndexSignatureDeclaration ( member ) ) ;
133
131
let additionalType : Tsoa . Type | undefined ;
@@ -256,7 +254,7 @@ export class TypeResolver {
256
254
const type = this . current . typeChecker . getTypeFromTypeNode ( this . typeNode ) ;
257
255
258
256
if ( type . isUnion ( ) ) {
259
- const literals = type . types . filter ( t => t . isLiteral ( ) ) . reduce ( ( acc , t : ts . LiteralType ) => [ ...acc , t . value . toString ( ) ] , [ ] ) ;
257
+ const literals = type . types . filter ( ( t ) : t is ts . LiteralType => t . isLiteral ( ) ) . reduce < string [ ] > ( ( acc , t : ts . LiteralType ) => [ ...acc , t . value . toString ( ) ] , [ ] ) ;
260
258
261
259
// Warn on nonsense (`number`, `typeof Symbol.iterator`)
262
260
if ( type . types . find ( t => ! t . isLiteral ( ) ) !== undefined ) {
@@ -361,7 +359,7 @@ export class TypeResolver {
361
359
362
360
if ( ts . isTemplateLiteralTypeNode ( this . typeNode ) ) {
363
361
const type = this . current . typeChecker . getTypeFromTypeNode ( this . referencer || this . typeNode ) ;
364
- if ( type . isUnion ( ) && type . types . every ( unionElementType => unionElementType . isStringLiteral ( ) ) ) {
362
+ if ( type . isUnion ( ) && type . types . every ( ( unionElementType ) : unionElementType is ts . StringLiteralType => unionElementType . isStringLiteral ( ) ) ) {
365
363
const stringLiteralEnum : Tsoa . EnumType = {
366
364
dataType : 'enum' ,
367
365
enums : type . types . map ( ( stringLiteralType : ts . StringLiteralType ) => stringLiteralType . value ) ,
@@ -544,7 +542,7 @@ export class TypeResolver {
544
542
return nodes ;
545
543
}
546
544
547
- private hasFlag ( type : ts . Symbol | ts . Declaration , flag ) {
545
+ private hasFlag ( type : ts . Symbol | ts . Declaration , flag : ts . NodeFlags | ts . SymbolFlags ) {
548
546
return ( type . flags & flag ) === flag ;
549
547
}
550
548
@@ -913,7 +911,9 @@ export class TypeResolver {
913
911
914
912
// Interface model
915
913
if ( ts . isInterfaceDeclaration ( node ) ) {
916
- return node . members . filter ( member => ! isIgnored ( member ) && ts . isPropertySignature ( member ) ) . map ( ( member : ts . PropertySignature ) => this . propertyFromSignature ( member , overrideToken ) ) ;
914
+ return node . members
915
+ . filter ( ( member ) : member is ts . PropertySignature => ! isIgnored ( member ) && ts . isPropertySignature ( member ) )
916
+ . map ( ( member : ts . PropertySignature ) => this . propertyFromSignature ( member , overrideToken ) ) ;
917
917
}
918
918
919
919
const properties : Array < ts . PropertyDeclaration | ts . ParameterDeclaration > = [ ] ;
0 commit comments