mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
AngularJS: give an interface to $http callback functions
- add IHttpPromiseCallback for both `error` and `success` promise calls use case is if we're passing around the callback, we don't want to be repeating that entire function declaration every time, and we cannot use `Function` as that doesn't satisfy the compiler. (see test case)
This commit is contained in:
Vendored
+6
-2
@@ -531,6 +531,10 @@ declare module ng {
|
||||
transformResponse?: any;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallback {
|
||||
(data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig): any;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallbackArg {
|
||||
data?: any;
|
||||
status?: number;
|
||||
@@ -539,8 +543,8 @@ declare module ng {
|
||||
}
|
||||
|
||||
interface IHttpPromise extends IPromise {
|
||||
success(callback: (data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig) => any): IHttpPromise;
|
||||
error(callback: (data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig) => any): IHttpPromise;
|
||||
success(callback: IHttpPromiseCallback): IHttpPromise;
|
||||
error(callback: IHttpPromiseCallback): IHttpPromise;
|
||||
then(successCallback: (response: IHttpPromiseCallbackArg) => any, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user