Skip to content
New issue

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

Update Typings #379

Closed
mzabriskie opened this issue Jul 16, 2016 · 11 comments · Fixed by #419
Closed

Update Typings #379

mzabriskie opened this issue Jul 16, 2016 · 11 comments · Fixed by #419
Assignees

Comments

@mzabriskie
Copy link
Member

This is a catch all for the multiple requests to update the type definition. Needs to be done for the next release.

@aendra-rininsland
Copy link

As somebody trying to use Axios with TypeScript for about two weeks now, I'm still not sure whether it's better to use the d.ts file in the main repo or the DefinitelyTyped definition. I started with the latter, which was fine until I tried to use Axios.all, which suffers from the issues mentioned in #253. I then did:

typings install github:mzabriskie/axios/axios.d.ts#8332392 --save --global

...To install the first-party ones and they seem to work far better.

I'm considering writing a blog entry about using Axios with TypeScript if there's any appetite for it, but it would be nice to get some clarification on which definitions are ultimately the most, uh, definitive? 😅

@JeroenNelen
Copy link

I'm getting is one: Property 'defaults' does not exist on type 'AxiosStatic'.
Because the typings don't seem to be defined for the default options.
If I find some time I can try to make a PRQ.

Kind regards,

@nickuraltsev
Copy link
Member

Just a heads up that I'm working on new definitions for axios.

@JeroenNelen
Copy link

@nickuraltsev in that case, I'll wait until your finished, are you also providing typings for the defaults option?

@nickuraltsev
Copy link
Member

@JeroenNelen Yes, will do

@nickuraltsev
Copy link
Member

New TypeScript definitions have landed to master.

@ericeslinger
Copy link

I'm not sure if I'm suffering from typescript-newbie syndrome, but I had to modify the package.json file distributed with axios to include "typings": "./axios.d.ts" in order to build a file that had an import from axios in my project (using gulp-typescript and tsc 2.0.0)

@shanekenney
Copy link

@ericeslinger The updates haven't been published to npm yet. #419 (comment)

@nickuraltsev
Copy link
Member

axios v0.14.0 has been released with these updates.

Note: Please use the following import statement to import axios in TypeScript:

import axios from 'axios';

axios.get('/foo')
  .then(response => console.log(response))
  .catch(error => console.log(error));

@renke
Copy link

renke commented Feb 18, 2017

Hi, I know this one is closed, but I noticed I can no longer type the response like this:

const res = await httpClient.post<string>(url, bookmark);

Edit: httpClient is an axios instance here.

I was using the @types/axios typing before and now use the typing that come with axios itself.

Any reason we can no longer type the response?

@cjke
Copy link

cjke commented Jun 4, 2017

Ditto - is there any way to use the old typings that supported this?

A sample of what I had set up looked like this:

export function index<T>(resource: string): Axios.IPromise<Axios.AxiosXHR<T>> {
    return axiosInstance.get<T>(resourceUrl(resource));
}

Meaning, in turn, I could do:

const response = await index<IProfile>('me');

And I would know that the response would be of type IProfile..

@axios axios locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants