From 73f1ee61d99dbdcfd5456a1f07a297bd69906ee2 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 16 Jan 2016 11:20:17 -0800 Subject: [PATCH] remove dependency on es6-promise.d.ts (it prevented using with other promise library definitions) --- axios/axios.d.ts | 264 ++++++++++++++++++++++++----------------------- 1 file changed, 137 insertions(+), 127 deletions(-) diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 48f57a73a..fd19caf94 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -3,160 +3,170 @@ // Definitions by: Marcel Buesing // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// declare module Axios { - /** - * - request body data type - */ - interface AxiosXHRConfigBase { + interface IThenable { + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; + } + + interface IPromise extends IThenable { + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; + catch(onRejected?: (error: any) => U | IThenable): IPromise; + } /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer + * - request body data type */ - transformRequest?: ((data:T) => U)|[(data:T) => U]; + interface AxiosXHRConfigBase { + + /** + * Change the request data before it is sent to the server. + * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + * The last function in the array must return a string or an ArrayBuffer + */ + transformRequest?: ((data: T) => U) | [(data: T) => U]; + + /** + * change the response data to be made before it is passed to then/catch + */ + transformResponse?: (data: T) => U; + + /** + * custom headers to be sent + */ + headers?: Object; + + /** + * URL parameters to be sent with the request + */ + params?: Object; + + /** + * indicates whether or not cross-site Access-Control requests + * should be made using credentials + */ + withCredentials?: boolean; + + /** + * indicates the type of data that the server will respond with + * options are 'arraybuffer', 'blob', 'document', 'json', 'text' + */ + responseType?: string; + + /** + * name of the cookie to use as a value for xsrf token + */ + xsrfCookieName?: string; + + /** + * name of the http header that carries the xsrf token value + */ + xsrfHeaderName?: string; + + } /** - * change the response data to be made before it is passed to then/catch + * - request body data type */ - transformResponse?: (data:T) => U; + interface AxiosXHRConfig extends AxiosXHRConfigBase { + /** + * server URL that will be used for the request, options are: + * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH + */ + url: string; + + /** + * request method to be used when making the request + */ + method?: string; + + /** + * data to be sent as the request body + * Only applicable for request methods 'PUT', 'POST', and 'PATCH' + * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash + */ + data?: T; + } /** - * custom headers to be sent + * - expected response type, + * - request body data type */ - headers?: Object; + interface AxiosXHR { + /** + * Response that was provided by the server + */ + data: T; + + /** + * HTTP status code from the server response + */ + status: number; + + /** + * HTTP status message from the server response + */ + statusText: string; + + /** + * headers that the server responded with + */ + headers: Object; + + /** + * config that was provided to `axios` for the request + */ + config: AxiosXHRConfig; + } /** - * URL parameters to be sent with the request + * - expected response type, + * - request body data type */ - params?: Object; + interface AxiosStatic { - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; + (config: AxiosXHRConfig): IPromise>; - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; + new (config: AxiosXHRConfig): IPromise>; - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: Object; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosStatic { - - (config: AxiosXHRConfig): Promise>; - - new (config: AxiosXHRConfig): Promise>; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = GET + */ + get(url: string, config?: AxiosXHRConfigBase): IPromise>; - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = DELETE + */ + delete(url: string, config?: AxiosXHRConfigBase): IPromise>; - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = HEAD + */ + head(url: string, config?: AxiosXHRConfigBase): IPromise>; - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = POST + */ + post(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = PUT + */ + put(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - } + /** + * convenience alias, method = PATCH + */ + patch(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; + } } declare var axios: Axios.AxiosStatic; declare module "axios" { - export = axios; + export = axios; }