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

Default import doesn't work correctly with typescript moduleResolution node16 #59

Closed
apottere opened this issue Feb 17, 2024 · 2 comments

Comments

@apottere
Copy link

apottere commented Feb 17, 2024

When I use "moduleResolution": "node16" in my tsconfig.json, I have to change my code as follows in order for it to compile:

import ShortUniqueId from 'short-unique-id';

// what I want to do
const generator = new ShortUniqueId(...);

// what I have to do
const generator = new ShortUniqueId.default(...);

It seems to be an issue with how the types are declared:
https://arethetypeswrong.github.io/?p=short-unique-id%405.0.3

That site claims that it might not work at runtime - this is something I haven't validated yet.

@bambuchaAdm
Copy link

Confirm that there is problem on node16 and nodenext.
It ends up with error like

error TS2351: This expression is not constructable.
Type 'typeof import("./node_modules/short-unique-id/dist/short-unique-id")' has no construct signatures.

@jeanlescure
Copy link
Collaborator

I've added the following specs in order to address these concerns:

https://github.com/simplyhexagonal/short-unique-id/tree/main/specs

Even with these, I am unable to reproduce the symptom with the current code-base.

I will close this issue, but if you run into the same problem with default import, feel free to open a new issue and include steps to reproduce.

Cheers ✌🏼

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

3 participants