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

[TypeScript] Won't work without esModuleInterop flag #62

Open
aggarwaldev opened this issue Jul 22, 2023 · 1 comment
Open

[TypeScript] Won't work without esModuleInterop flag #62

aggarwaldev opened this issue Jul 22, 2023 · 1 comment

Comments

@aggarwaldev
Copy link

Hi,

Great module. Thank you for it.

However, I'm facing issues while using it in a TypeScript project. I have tried the following approaches:

  • As per README
    (import UserAgent from 'user-agents';)
    I get TypeError: user_agents_1.default is not a constructor error

  • Based on Not work require().default #10
    (import * as UserAgent from 'user-agents';)
    I get TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export. error

I investigated and I tried to learn more about the issue, you should check this StackOverflow.

Is it possible to fix it in the near-term so as to avoid using esModuleInterop flag?

@thisiseddy-ab
Copy link

Hi,

Great module. Thank you for it.

However, I'm facing issues while using it in a TypeScript project. I have tried the following approaches:

* As per README
  (`import UserAgent from 'user-agents';`)
  I get `TypeError: user_agents_1.default is not a constructor` error

* Based on [Not work require().default #10](https://github.com/intoli/user-agents/issues/10)
  (`import * as UserAgent from 'user-agents';`)
  I get `TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.` error

I investigated and I tried to learn more about the issue, you should check this StackOverflow.

Is it possible to fix it in the near-term so as to avoid using esModuleInterop flag?

did you fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants