2
0
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:
Dmitriy Mozgovoy
2022-05-03 21:29:50 +03:00
committed by GitHub
parent e52af17ee8
commit c07998a621
2 changed files with 9 additions and 0 deletions
Vendored
+5
View File
@@ -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;
+4
View File
@@ -371,3 +371,7 @@ axios.get('/user')
const axiosError: AxiosError = error; const axiosError: AxiosError = error;
} }
}); });
// FormData
axios.toFormData({x: 1}, new FormData());