mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Updating TypeScript definitions for axios.all and axios.spread
This commit is contained in:
Vendored
+2
-2
@@ -83,8 +83,8 @@ export interface AxiosStatic extends AxiosInstance {
|
||||
(config: AxiosRequestConfig): AxiosPromise;
|
||||
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||
create(config?: AxiosRequestConfig): AxiosInstance;
|
||||
all(iterable: any): any;
|
||||
spread(callback: any): any;
|
||||
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
|
||||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||
}
|
||||
|
||||
declare const Axios: AxiosStatic;
|
||||
|
||||
@@ -203,3 +203,17 @@ const adapter: AxiosAdapter = (config: AxiosRequestConfig) => {
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user