File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
packages/cli/src/metadataGeneration
tests/fixtures/controllers Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,11 @@ export class GenerateMetadataError extends Error {
11
11
}
12
12
13
13
export class GenerateMetaDataWarning {
14
- constructor ( private message : string , private node : Node | TypeNode , private onlyCurrent = false ) { }
14
+ constructor (
15
+ private message : string ,
16
+ private node : Node | TypeNode ,
17
+ private onlyCurrent = false ,
18
+ ) { }
15
19
16
20
toString ( ) {
17
21
return `Warning: ${ this . message } \n${ prettyLocationOfNode ( this . node ) } \n${ prettyTroubleCause ( this . node , this . onlyCurrent ) } ` ;
@@ -34,9 +38,9 @@ export function prettyLocationOfNode(node: Node | TypeNode) {
34
38
export function prettyTroubleCause ( node : Node | TypeNode , onlyCurrent = false ) {
35
39
let name : string ;
36
40
if ( onlyCurrent || ! node . parent ) {
37
- name = node . pos !== - 1 ? node . getText ( ) : ( ( node as any ) . name ?. text || '<unknown name>' ) ;
41
+ name = node . pos !== - 1 && node . parent ? node . getText ( ) : ( node as any ) . name ?. text || '<unknown name>' ;
38
42
} else {
39
- name = node . parent . pos !== - 1 ? node . parent . getText ( ) : ( ( node as any ) . parent . name ?. text || '<unknown name>' ) ;
43
+ name = node . parent . pos !== - 1 ? node . parent . getText ( ) : ( node as any ) . parent . name ?. text || '<unknown name>' ;
40
44
}
41
45
return `This was caused by '${ name } '` ;
42
46
}
Original file line number Diff line number Diff line change @@ -112,6 +112,14 @@ export class GetTestController extends Controller {
112
112
return { } as TsoaTest . TestModel73 ;
113
113
}
114
114
115
+ @Get ( 'NamespaceWithTypeCastedObject' )
116
+ public async getNamespaceWithTypeCastedObject ( ) {
117
+ const test = { value : 'test' } ;
118
+ return {
119
+ value : test as TsoaTest . TestModel73 ,
120
+ } ;
121
+ }
122
+
115
123
@Get ( 'Multi' )
116
124
public async getMultipleModels ( ) : Promise < TestModel [ ] > {
117
125
return [ new ModelService ( ) . getModel ( ) , new ModelService ( ) . getModel ( ) , new ModelService ( ) . getModel ( ) ] ;
You can’t perform that action at this time.
0 commit comments