Skip to content

Typescript imports not working #5082

Closed

Description

@AuspeXeu

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.

Activity

  1. Enngage commented on Oct 10, 2022

    @Enngage

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

  2. Enngage commented on Oct 10, 2022

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

  3. AuspeXeu commented on Oct 10, 2022

    @AuspeXeu
    Author

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

  4. flovouin commented on Oct 10, 2022

    @flovouin

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

  5. danielsss commented on Oct 11, 2022

    @danielsss

    +1

  6. apt-bh commented on Oct 11, 2022

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

  7. Enngage commented on Oct 11, 2022

    @Enngage

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

  8. AuspeXeu commented on Oct 11, 2022

    @AuspeXeu
    Author

    @Enngage how about 1.1.2?

  9. aka-somix commented on Oct 11, 2022

    @aka-somix

    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.

  10. scflode commented on Oct 13, 2022

    @scflode

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

  11. apt-bh commented on Oct 13, 2022

    @apt-bh

    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 ?

  12. jasonsaayman commented on Oct 13, 2022

    @jasonsaayman
    Member

    @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

  13. apt-bh commented on Oct 13, 2022

    @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

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

  14. jasonsaayman commented on Oct 14, 2022

    @jasonsaayman
    Member

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

  15. ani-ali commented on Oct 15, 2022

    @ani-ali

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

  16. Systerr commented on Oct 17, 2022

    @Systerr

    v1.1.3 still not working

  17. bozorgmehr96 commented on Oct 23, 2022

    @bozorgmehr96

    +1

  18. tgbv commented on Oct 23, 2022

    @tgbv

    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.

  19. czy88840616 commented on Oct 23, 2022

    @czy88840616

    Same problem, I had to fall back to 1.1.0

  20. jimboowens commented on Oct 27, 2022

    @jimboowens

    +1

  21. nizamani commented on Oct 27, 2022

    @nizamani

    +1 having same issue

  22. GabrielFrohlich commented on Nov 17, 2022

    @GabrielFrohlich

    Problem persists in 1.1.3 for me

  23. aymendps commented on Nov 22, 2022

    @aymendps

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions