mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Added generic TS types for the exposed toFormData helper; (#4668)
This commit is contained in:
Vendored
+5
@@ -237,6 +237,10 @@ export interface AxiosInstance extends Axios {
|
|||||||
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GenericFormData {
|
||||||
|
append(name: string, value: any, options?: any): any;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AxiosStatic extends AxiosInstance {
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
create(config?: AxiosRequestConfig): AxiosInstance;
|
create(config?: AxiosRequestConfig): AxiosInstance;
|
||||||
Cancel: CancelStatic;
|
Cancel: CancelStatic;
|
||||||
@@ -248,6 +252,7 @@ export interface AxiosStatic extends AxiosInstance {
|
|||||||
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
||||||
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
||||||
isAxiosError(payload: any): payload is AxiosError;
|
isAxiosError(payload: any): payload is AxiosError;
|
||||||
|
toFormData(sourceObj: object, targetFormData?: GenericFormData): GenericFormData;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const axios: AxiosStatic;
|
declare const axios: AxiosStatic;
|
||||||
|
|||||||
@@ -371,3 +371,7 @@ axios.get('/user')
|
|||||||
const axiosError: AxiosError = error;
|
const axiosError: AxiosError = error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// FormData
|
||||||
|
|
||||||
|
axios.toFormData({x: 1}, new FormData());
|
||||||
|
|||||||
Reference in New Issue
Block a user