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.
If I change my import to:
import * as axios from 'axios';
I get a compiler error:
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
- Pin Axios to 1.1.0 because of https://github.com/axios/axios/issues/5082 — committed to wate-labs/wate by scflode 2 years ago
- Bump axios from 0.27.2 to 1.1.2 (#134) * Bump axios from 0.27.2 to 1.1.2 Bumps [axios](https://github.com/axios/axios) from 0.27.2 to 1.1.2. - [Release notes](https://github.com/axios/axios/relea... — committed to wate-labs/wate by dependabot[bot] 2 years ago
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.