mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
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:
parent
6b068086bf
commit
30b9603742
@ -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
|
||||
|
||||
4
types/angular/index.d.ts
vendored
4
types/angular/index.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user