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

bug: Incorrect type declaration files for Node16/NodeNext module resolution #3034

Open
jcarrus opened this issue May 14, 2024 · 1 comment
Open

Comments

@jcarrus
Copy link

jcarrus commented May 14, 2024

What version of daisyUI are you using?

4.11.1

Which browsers are you seeing the problem on?

All browsers

Reproduction URL

https://stackblitz.com/edit/daisyui-vite-uhsszc?file=src%2Fmain.ts

Describe your issue

I think the .d.ts files are slightly incorrect. If you check https://arethetypeswrong.github.io/?p=daisyui%404.11.1

image

There in an incorrect default export. The error message on that site sums up the issue well:

The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default.

For this reason, I think the .d.ts files need to say export = rather than export default in places where the corresponding JS is module.exports = .

I discovered this while transitioning an ESM project (package.json type = "module") that uses TypeScript from "Node10" module resolution to "Node16" and have had an erroneous TS warning.

There's a reproduction on StackBlitz that I walk through by video below since this is a different kind of problem.

2024-05-14.08-04-46.mp4
Copy link

Thank you @jcarrus for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

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

1 participant