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 types should work with moduleResolution node #116

Closed
aldenquimby opened this issue Oct 3, 2024 · 4 comments
Closed

TypeScript types should work with moduleResolution node #116

aldenquimby opened this issue Oct 3, 2024 · 4 comments

Comments

@aldenquimby
Copy link

I installed mupdf in a TS project and ran into this error:

image

Runtime code works fine, but TypeScript complains.

Adding the following to mupdf/package.json fixes the issue:

  "main": "./dist/mupdf.js",
  "types": "./dist/mupdf.d.ts",
@ccxvii
Copy link
Collaborator

ccxvii commented Oct 3, 2024

This error could be because you haven't set the moduleResolution properly.

Did you use the ".mts" suffix on your typescript source file, or did you run the "npm pkg set type=module" command?

If not, please try to do that first.

@aldenquimby
Copy link
Author

aldenquimby commented Oct 4, 2024

@ccxvii I do have type=module, but I'm using an older moduleResolution. I'll try updating to see if that fixes it!

I see now your docs say nodenext is required. I believe if you add main + types to the package.json, you could drop that requirement, making this a more widely usable library

But in the meantime, I'll see if I can get that resolution working in my project!

@aldenquimby aldenquimby changed the title TypeScript types should work out of the box TypeScript types should work with moduleResolution node Oct 4, 2024
@aldenquimby
Copy link
Author

aldenquimby commented Oct 4, 2024

@ccxvii i confirmed that upgrading my moduleResolution fixed the issue, so feel free to close if you'd like! It's worth noting this was a decent effort, because many older libraries only work with moduleResolution=node. So it may still be nice for you to support the older moduleResolution

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

4 participants
@ccxvii @aldenquimby @jamie-lemon and others