Improve types of 'instantiate' and 'invoke' of IInjectorService.

The result is inferred form the argument, which removes the need of any cast.
This commit is contained in:
Mateusz Greszta 2017-04-18 16:59:54 +02:00
parent 6b068086bf
commit 30b9603742
2 changed files with 18 additions and 2 deletions

View File

@ -470,6 +470,22 @@ namespace TestInjector {
$injector.annotate(() => {});
$injector.annotate(() => {}, true);
// $injector.instantiate
{
class Foobar {
constructor($q) {}
}
let result: Foobar = $injector.instantiate(Foobar);
}
// $injector.invoke
{
function foobar(v: boolean): number {
return 7;
}
let result: number = $injector.invoke(foobar);
}
}
// Promise signature tests

View File

@ -1978,9 +1978,9 @@ declare namespace angular {
get(name: '$window'): IWindowService;
get<T>(name: '$xhrFactory'): IXhrFactory<T>;
has(name: string): boolean;
instantiate<T>(typeConstructor: Function, locals?: any): T;
instantiate<T>(typeConstructor: {new(...args: any[]): T}, locals?: any): T;
invoke(inlineAnnotatedFunction: any[]): any;
invoke(func: Function, context?: any, locals?: any): any;
invoke<T>(func: (...args: any[]) => T, context?: any, locals?: any): T;
strictDi: boolean;
}