saadeghi/daisyui

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

jcarrus opened this issue · 2 comments

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

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.

Fixed by #3097