2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Updating TypeScript definitions for axios.all and axios.spread

This commit is contained in:
Nick Uraltsev
2016-08-16 19:03:28 -07:00
parent 9a5e77bf6e
commit 48549c8de7
2 changed files with 16 additions and 2 deletions
Vendored
+2 -2
View File
@@ -83,8 +83,8 @@ export interface AxiosStatic extends AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise; (config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise; (url: string, config?: AxiosRequestConfig): AxiosPromise;
create(config?: AxiosRequestConfig): AxiosInstance; create(config?: AxiosRequestConfig): AxiosInstance;
all(iterable: any): any; all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
spread(callback: any): any; spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
} }
declare const Axios: AxiosStatic; declare const Axios: AxiosStatic;
+14
View File
@@ -203,3 +203,17 @@ const adapter: AxiosAdapter = (config: AxiosRequestConfig) => {
}; };
axios.defaults.adapter = adapter; axios.defaults.adapter = adapter;
// axios.all
const promises = [
Promise.resolve(1),
Promise.resolve(2)
];
const promise: Promise<number[]> = axios.all(promises);
// axios.spread
const fn1 = (a: number, b: number, c: number) => `${a}-${b}-${c}`;
const fn2: (arr: number[]) => string = axios.spread(fn1);