File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
src/transformer/descriptor/method Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -7,21 +7,21 @@ export function GetReturnTypeFromBodyDescriptor(node: ts.ArrowFunction | ts.Func
77 return GetDescriptor ( GetReturnNodeFromBody ( node ) , scope ) ;
88}
99
10- export function GetReturnNodeFromBody ( node : ts . FunctionLikeDeclaration ) : ts . Node {
11- let returnValue : ts . Node | undefined ;
10+ export function GetReturnNodeFromBody ( node : ts . FunctionLikeDeclaration ) : ts . Expression {
11+ let returnValue : ts . Expression | undefined ;
1212
1313 const functionBody : ts . ConciseBody | undefined = node . body ;
1414
1515 if ( functionBody && ts . isBlock ( functionBody ) ) {
16- const returnStatement : ts . ReturnStatement = GetReturnStatement ( functionBody ) ;
16+ const returnStatement : ts . ReturnStatement | undefined = GetReturnStatement ( functionBody ) ;
1717
1818 if ( returnStatement ) {
1919 returnValue = returnStatement . expression ;
2020 } else {
2121 returnValue = GetNullDescriptor ( ) ;
2222 }
2323 } else {
24- returnValue = node . body ;
24+ returnValue = functionBody ;
2525 }
2626
2727 if ( ! returnValue ) {
@@ -31,6 +31,8 @@ export function GetReturnNodeFromBody(node: ts.FunctionLikeDeclaration): ts.Node
3131 return returnValue ;
3232}
3333
34- function GetReturnStatement ( body : ts . FunctionBody ) : ts . ReturnStatement {
35- return body . statements . find ( ( statement : ts . Statement ) => statement . kind === ts . SyntaxKind . ReturnStatement ) as ts . ReturnStatement ;
34+ function GetReturnStatement ( body : ts . FunctionBody ) : ts . ReturnStatement | undefined {
35+ return body . statements . find (
36+ ( statement : ts . Statement ) : statement is ts . ReturnStatement => statement . kind === ts . SyntaxKind . ReturnStatement ,
37+ ) ;
3638}
You can’t perform that action at this time.
0 commit comments