Added generics to IHttpPromise and some missing properties/overloads

I know you haven't used generics so far so I hope this is a welcome
change - the only nuisance is that it will "break" current compilation
but will increase type safety by far.

Also added params to ICurrentRoute and inline injection notation to
$provide.decorator as per
https://github.com/borisyankov/DefinitelyTyped/issues/799
This commit is contained in:
Georgios Diamantopoulos
2013-08-05 12:06:53 +03:00
parent 2089d27c7f
commit 25c88427fb
2 changed files with 131 additions and 132 deletions
+11 -8
View File
@@ -537,21 +537,21 @@ declare module ng {
transformResponse?: any;
}
interface IHttpPromiseCallback {
(data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig): any;
interface IHttpPromiseCallback<T> {
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): any;
}
interface IHttpPromiseCallbackArg {
data?: any;
interface IHttpPromiseCallbackArg<T> {
data?: T;
status?: number;
headers?: (headerName: string) => string;
config?: IRequestConfig;
}
interface IHttpPromise extends IPromise {
success(callback: IHttpPromiseCallback): IHttpPromise;
error(callback: IHttpPromiseCallback): IHttpPromise;
then(successCallback: (response: IHttpPromiseCallbackArg) => any, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
interface IHttpPromise<T> extends IPromise {
success(callback: IHttpPromiseCallback<T>): IHttpPromise;
error(callback: IHttpPromiseCallback<T>): IHttpPromise;
then(successCallback: (response: IHttpPromiseCallbackArg<T>) => any, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise;
}
interface IHttpProvider extends IServiceProvider {
@@ -639,6 +639,8 @@ declare module ng {
$scope: IScope;
$template: string;
};
params: any;
}
interface IRouteProvider extends IServiceProvider {
@@ -693,6 +695,7 @@ declare module ng {
constant(name: string, value: any): void;
decorator(name: string, decorator: Function): void;
decorator(name: string, decoratorInline: any[]): void;
factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider;
provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider;
provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider;