We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi guys!
I noticed that typings on REST methods could be improved to make it simpler to use
let's take latest typings for post on v1.6.7 as an example
post
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
so if I'd like have everything typped I have to do it this way:
type Params = {} type Response = {} axios.post<Response, AxiosResponse<Response>, Params>(....
don't you agree that being forced to Response, AxiosResponse<Response> is not cool?
Response, AxiosResponse<Response>
let's try to change typing definition of post to look like this:
post<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>;
so now if I'd like to have it typed I'd have to:
type Params = {} type Response = {} axios.post<Params, Response>(....
simple and elegant, right? :)
I've changed the order of D and T to match my way of thinking - first you need to input some data (D) and you will receive response (T)
here are all of my tweeks to your typings:
request<T = any, D = any>(config: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; get<T = any, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; delete<T = any, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; head<T = any, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; options<D = any, T = any>(url: string, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; post<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; put<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; patch<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; postForm<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; putForm<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>; patchForm<D = any, T = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>;
No response
The text was updated successfully, but these errors were encountered:
sure seems nice enough, can you propose a solution in a pr?
Sorry, something went wrong.
sure give me a moment :)
@jasonsaayman here it is #6239
No branches or pull requests
Is your feature request related to a problem? Please describe.
Hi guys!
I noticed that typings on REST methods could be improved to make it simpler to use
let's take latest typings for
post
on v1.6.7 as an exampleso if I'd like have everything typped I have to do it this way:
don't you agree that being forced to
Response, AxiosResponse<Response>
is not cool?Describe the solution you'd like
let's try to change typing definition of
post
to look like this:so now if I'd like to have it typed I'd have to:
simple and elegant, right? :)
Describe alternatives you've considered
I've changed the order of D and T to match my way of thinking - first you need to input some data (D) and you will receive response (T)
here are all of my tweeks to your typings:
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: