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

Import in Typescript environment with NodeJS? #196

Closed
Emsu opened this issue May 7, 2023 · 3 comments · Fixed by #197
Closed

Import in Typescript environment with NodeJS? #196

Emsu opened this issue May 7, 2023 · 3 comments · Fixed by #197

Comments

@Emsu
Copy link

Emsu commented May 7, 2023

When I try importing with
import moize from "moize/mjs/index.mjs";

I get the following error:
error TS7016: Could not find a declaration file for module 'moize/mjs/index.mjs'

It seems like the type file is only found if I import moize from 'moize'; however the build from that import causes other issues in NodeJS as well.

What's the recommended way to import moize via ESM or to configure tsconfig.json for an ESM Node environment with Typescript?

@Emsu
Copy link
Author

Emsu commented May 7, 2023

Currently it seems to me it might be similar to the issue described here? https://stackoverflow.com/questions/72457791/typescript-packages-that-ship-with-mjs-and-d-ts-but-without-d-mts-how-to-i

Basically the types field is resolving to CommonJS for Typescript but for ESM it's loading the .mjs file without types which is leading to Typescript with an ESM import to fail? Does that sound plausible?

@planttheidea
Copy link
Owner

Yeah it's the same issue as experienced with micro-memoize. I'll try to add a fix for it later tonight like I did there.

@planttheidea
Copy link
Owner

This should be fixed with the 6.1.6 release. Let me know if you have any more issues!

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

Successfully merging a pull request may close this issue.

2 participants