axios: Typescript imports not working

I am importing axios as follows into my typescript project:

import axios from 'axios';

which compiles without a problem, however the resulting javascript code throws an exception. image If I change my import to:

import * as axios from 'axios';

I get a compiler error: image But at least the resulting javascript code runs without issues.

Seems like there’s kind of a mismatch here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 23 (2 by maintainers)

Commits related to this issue

Most upvoted comments

v1.1.3 still not working

@GabrielModog that’s literally what the first code block in my issue description is 😉

If that’s an option for you, a workaround is to enable esModuleInterop.

Same problem, I had to fall back to 1.1.0

I have done testing and this is now working plus the common JS use is working, I will do a release tonight

@GabrielModog, yeah, that was the code we had in our codebase (as opposed to what @AuspeXeu has), but the results are the same. I believe something broke between the releases I mentioned.