diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index e6be93a6af..d01dbd25b8 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -484,7 +484,14 @@ namespace TestInjector { function foobar(v: boolean): number { return 7; } - let result: number = $injector.invoke(foobar); + let result = $injector.invoke(foobar); + if (!(typeof result === 'number')) { + // This fails to compile if 'result' is not exactly a number. + let expectNever: never = result; + } + + let anyFunction: Function = foobar; + let anyResult: string = $injector.invoke(anyFunction); } } diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index 194ccf8205..1d59854d9d 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1981,6 +1981,7 @@ declare namespace angular { instantiate(typeConstructor: {new(...args: any[]): T}, locals?: any): T; invoke(inlineAnnotatedFunction: any[]): any; invoke(func: (...args: any[]) => T, context?: any, locals?: any): T; + invoke(func: Function, context?: any, locals?: any): any; strictDi: boolean; }