-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Imports fail with TS "moduleResolution": "nodenext" #4991
Comments
I just discovered that the types are correctly imported for @mantine/hooks, but not for @mantine/core and @mantine/dates. I looked at the tsconfig for them, and there are differences: for @mantine/core (does not work)
for @mantine/hooks (does work)
Could this be the problem? It is actually a very annoying bug, as I practically can't use TypeScript with anything imported from @mantine/core, and I need to put //@ts-ignore to too many places in my codebase. I hope it's an easy fix and can be patched soon! |
I have also run into this. Attached is a minimal project that shows the issue. Here's what's going on:
Phew! Now what can we do to fix this? There's a few things that can work:
It looks like there's already something in the build process for rewriting imports, so either way this is probably a simple fix. |
It looks like in #4792 there were some issues that showed up due to other packages assuming the wrong module format, so the I assume just the main index file being ".d.mts" was enough? If so, only the imports in that file need to have their imports adjusted, like |
@simonszalai in the meantime, try this workaround in your tsconfig.json: "compilerOptions": {
"paths": {
"@mantine/core": ["./node_modules/@mantine/core/lib/index.d.ts"]
}
} |
@waweber amazing, that worked, thank you! |
This comment was marked as off-topic.
This comment was marked as off-topic.
@sid374 I would guess its something like the datatable library resolving and importing a different copy of the mantine libs due to the workaround. I haven't had time, but in a few weeks I think I will poke around with the build scripts to come up with an actual patch if someone else doesn't get to it |
@simonszalai the fix for this is included in version 7.5.2, so try it out and see if it works now without the workaround |
What package has an issue
@mantine/core
Describe the bug
When I set "moduleResolution": "nodenext" in tsconfig, TS throws an error for all Mantine imports. I am using the Epic Remix Stack from Kent C. Dodds, and if I go back to "moduleResolution": "node", Mantine imports work fine, but all kinds of other errors pop up all over the project. Now I'm just adding a @ts-ignore for each Mantine import, but that makes auto-import impossible, which is not great.
Is there a better workaround? What would it take to fix this?
What version of @mantine/* packages do you have in package.json? (Note that all @mantine/* packages must have the same version in order to work correctly)
7.1.2
If possible, please include a link to a codesandbox with the reproduced problem
No response
Do you know how to fix the issue
No
Are you willing to participate in fixing this issue and create a pull request with the fix
Yes
Possible fix
No response
The text was updated successfully, but these errors were encountered: