Describe the bug
The TS types for CJS are not exported correctly, which causes the "module": "node16" and "moduleResolution": "node16" to report errors. See this repo for reproduction: https://github.com/zirkelc/happy-dom-types-node16
Screenshots
If applicable, add screenshots to help explain your problem.
When you export CJS files as index.cjs, then you need to export the corresponding type declarations as index.d.cts and not index.d.ts. Here is a short video that demonstrates the fix:
Describe the bug The TS types for CJS are not exported correctly, which causes the
"module": "node16"
and"moduleResolution": "node16"
to report errors. See this repo for reproduction: https://github.com/zirkelc/happy-dom-types-node16Screenshots If applicable, add screenshots to help explain your problem.![2024-05-08_08-59-39](https://github.com/capricorn86/happy-dom/assets/950244/2ba28961-55c7-4a0c-9deb-1797a328a266)
Additional context I have experienced this issue multiple times with different packages. For example, LangChain had the same problem which I described here: https://github.com/langchain-ai/langchainjs/issues/4060#issuecomment-1897863598
When you export CJS files as
index.cjs
, then you need to export the corresponding type declarations asindex.d.cts
and notindex.d.ts
. Here is a short video that demonstrates the fix:https://github.com/capricorn86/happy-dom/assets/950244/19b010cf-7de6-4876-af16-d3462b716ab5
As you can see, all you need to do is to change the file extension.
Last but not least: thank you for work on this package!