axios icon indicating copy to clipboard operation
axios copied to clipboard

Typescript imports not working

Open AuspeXeu opened this issue 2 years ago • 19 comments

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.

AuspeXeu avatar Oct 10 '22 07:10 AuspeXeu

Same issue here ;) Works in 1.1.0 but doesn't in 1.1.2

Enngage avatar Oct 10 '22 07:10 Enngage

@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.

Enngage avatar Oct 10 '22 08:10 Enngage

@GabrielModog that's literally what the first code block in my issue description is ;)

AuspeXeu avatar Oct 10 '22 08:10 AuspeXeu

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

flovouin avatar Oct 10 '22 09:10 flovouin

+1

danielsss avatar Oct 11 '22 03:10 danielsss

+1

It doesn't work since v1.0.0 (0.27.2 works fine with the same codebase), importing axios results in an undefined variable. Any idea what to do ?

apt-bh avatar Oct 11 '22 09:10 apt-bh

+1

It doesn't work since v1.0.0 (0.27.2 works fine with the same codebase), importing axios results in an undefined variable. Any idea what to do ?

It works in 1.1.0, we are using that successfully.

Enngage avatar Oct 11 '22 10:10 Enngage

@Enngage how about 1.1.2?

AuspeXeu avatar Oct 11 '22 12:10 AuspeXeu

I am having the same problem with the 1.1.2 and i cannot seem to make it work with 1.0.0 as well.

aka-somix avatar Oct 11 '22 16:10 aka-somix

This seems to have been introduced in 1.1.1. 1.1.0 is the last working version.

scflode avatar Oct 13 '22 14:10 scflode

This seems to have been introduced in 1.1.1. 1.1.0 is the last working version.

Indeed, thanks for pointing that out. I have the issue both on 1.0.0 and 1.1.1. However 1.1.0 is working fine. So do you think the bug may have been introduced, removed and reintroduced ?

apt-bh avatar Oct 13 '22 15:10 apt-bh

@apt-bh yeah this is actually what happened. There is an oddity that has crept in with the build process and until we locked it down we mended common JS as this is by far the widest implementation of the library. I have merged a PR recently that I am going to test and hopefully that solves all issues for us with regard to this. Watch for a v1.1.3

jasonsaayman avatar Oct 13 '22 20:10 jasonsaayman

@apt-bh yeah this is actually what happened. There is an oddity that has crept in with the build process and until we locked it down we mended common JS as this is by far the widest implementation of the library. I have merged a PR recently that I am going to test and hopefully that solves all issues for us with regard to this. Watch for a v1.1.3

Thanks for the quick reply, I'll be watching for the new release

apt-bh avatar Oct 13 '22 20:10 apt-bh

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

jasonsaayman avatar Oct 14 '22 11:10 jasonsaayman

I just facing the same issue in typescript but I tried use "axios": "^0.27.2", and working just fine

Anishali2 avatar Oct 15 '22 05:10 Anishali2

v1.1.3 still not working

Systerr avatar Oct 17 '22 17:10 Systerr

+1

bozorgmehr96 avatar Oct 23 '22 11:10 bozorgmehr96

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

Solves it for me. Though I had to change the syntax of other imports I have.

tgbv avatar Oct 23 '22 12:10 tgbv

Same problem, I had to fall back to 1.1.0

czy88840616 avatar Oct 23 '22 14:10 czy88840616

+1

jimboowens avatar Oct 27 '22 19:10 jimboowens

+1 having same issue

nizamani avatar Oct 27 '22 21:10 nizamani

Problem persists in 1.1.3 for me

GabrielFrohlich avatar Nov 17 '22 18:11 GabrielFrohlich

Facing this issue as well on 1.1.3. Any updates on this?

aymendps avatar Nov 22 '22 18:11 aymendps