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

Getting typescript errors #364

Open
chan-dev opened this issue Jun 15, 2023 · 5 comments
Open

Getting typescript errors #364

chan-dev opened this issue Jun 15, 2023 · 5 comments

Comments

@chan-dev
Copy link

image

I'm getting this error in a nodejs 18 + typescript app. Even though, the build works successfully.
Just one thing that may needed to be sorted out

@olexandr-mazepa
Copy link
Collaborator

Hello @chan-dev
It looks like something related either to IDE types parsing or way of packages import, but unfortunately I can't reproduce it.
What type of project are you working on?
Which version of TS is this?
Does the project targets the Node.js environment or browser page?
Do you use any frameworks?

@md-redwan-hossain
Copy link

md-redwan-hossain commented Jul 2, 2023

I am also getting this error. Tried with Vscode and WebStorm, the Error pops up in both of them.
I am using es module to import mailgun in a nodeJS 18 project with typescript 5.0.4. The project targets Node.js environment and I am using expressJS.

The problem arises when "type": "module" is defined in package.json

This expression is not constructable.
Type 'typeof import("/home/.../mailgun.js/index")' has no construct signatures.

@FrankHeijden
Copy link

FrankHeijden commented Jul 12, 2023

Duplicate of #350
@olexandr-mazepa this is because they use ESM, are there any plans on making mailgun.js compatible?

@olexandr-mazepa
Copy link
Collaborator

Hi @FrankHeijden
Yeap, there is a high-level plan to add ESM support, but unfortunately, there are no strict dates I can share with you.

There are a few things I am going to do before this action.
For example, improve tests #374 to be sure that changes will not break current exports and replace the Webpack with Rollup for bundling in addition to usual bug fixing.
So I think you may use these actions as a way to track how far, I am currently from adding ESM support.

P.S. Just in case you have time and motivation to work on something of mentioned items I appreciate any support.

@Vortec4800
Copy link

FYI for people trying to use this with Typescript in the meantime, I found this which will work until ESM is fully supported:

import Mailgun from 'mailgun.js';
import FormData from 'form-data';
const mailgun = new Mailgun.default(FormData);

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