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

Export Default? #55

Closed
tstachl opened this issue Apr 28, 2020 · 5 comments
Closed

Export Default? #55

tstachl opened this issue Apr 28, 2020 · 5 comments

Comments

@tstachl
Copy link

tstachl commented Apr 28, 2020

export default messagebird;

Can you guys fix your Typescript types to not use export default, it doesn't work and I'm getting the following type error:

TypeError: messagebird_1.default is not a function

Here is also some additional reading on why export default is bad:

@aodinok
Copy link
Contributor

aodinok commented May 4, 2020

Hey @tstachl, can you please check now, I've added example how to use it with TypeScript and fixed the typings. Please let me know if still doesn't work for you.

@tstachl
Copy link
Author

tstachl commented May 4, 2020

Hey @aodinok, it works with esModuleInterop, thanks for the tip. I decided to dynamically load messagebird now like so:

import("messagebird").then((messagebird: any) => {
  const client = messagebird("API_KEY");
  return new Promise((resolve, reject) => {
    client.balance.read((err, data) => {
      if (err) reject(err);
      resolve(data);
    });
  });
});

@bahador-r
Copy link

same issue

@etiennea
Copy link

Using esModuleInterop is not an ideal solution

@VersusF
Copy link

VersusF commented Jan 24, 2023

Hello, any update on this? esModuleInterop is not compatible with other libraries that we use. Currently the only solution is:

// eslint-disable-next-line @typescript-eslint/no-var-requires
this.messageBirdClient = require("messagebird")("MESSAGEBIRD_KEY");

But it is not the best one

aodinok added a commit that referenced this issue Jan 24, 2023
aodinok added a commit that referenced this issue Jan 24, 2023
aodinok added a commit that referenced this issue Jan 24, 2023
aodinok added a commit that referenced this issue Jan 24, 2023
aodinok added a commit that referenced this issue Jan 24, 2023
aodinok added a commit that referenced this issue Jan 25, 2023
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

5 participants