File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,9 @@ export class TSHelper {
370370 if ( i >= 0 ) {
371371 const parentSignature = checker . getResolvedSignature ( signatureDeclaration . parent ) ;
372372 const parentSignatureDeclaration = parentSignature . getDeclaration ( ) ;
373- declType = checker . getTypeAtLocation ( parentSignatureDeclaration . parameters [ i ] ) ;
373+ if ( parentSignatureDeclaration ) {
374+ declType = checker . getTypeAtLocation ( parentSignatureDeclaration . parameters [ i ] ) ;
375+ }
374376 }
375377 } else if ( ts . isReturnStatement ( signatureDeclaration . parent ) ) {
376378 declType = this . getContainingFunctionReturnType ( signatureDeclaration . parent , checker ) ;
Original file line number Diff line number Diff line change @@ -300,6 +300,20 @@ export class AssignmentTests {
300300 Expect ( result ) . toBe ( expectResult ) ;
301301 }
302302
303+ @TestCase ( "s => s" , "foo" )
304+ @TestCase ( "function(s) { return s; }" , "foo" )
305+ @TestCase ( "function(this: void, s: string) { return s; }" , "foo" )
306+ @Test ( "Valid function expression argument with no signature" )
307+ public validFunctionExpressionArgumentNoSignature ( func : string , expectResult : string ) : void {
308+ const code = `${ AssignmentTests . funcAssignTestCode }
309+ const takesFunc: any = (fn: (s: string) => string) => {
310+ return (fn as any)("foo");
311+ }
312+ return takesFunc(${ func } );` ;
313+ const result = util . transpileAndExecute ( code ) ;
314+ Expect ( result ) . toBe ( expectResult ) ;
315+ }
316+
303317 @TestCase ( "func" , "foo+func" )
304318 @TestCase ( "lambda" , "foo+lambda" )
305319 @TestCase ( "Foo.staticMethod" , "foo+staticMethod" )
You can’t perform that action at this time.
0 commit comments