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: Types for CJS are not exported correctly #1430

Open
zirkelc opened this issue May 8, 2024 · 0 comments
Open

Bug: Types for CJS are not exported correctly #1430

zirkelc opened this issue May 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zirkelc
Copy link

zirkelc commented May 8, 2024

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.
2024-05-08_08-59-39

Additional context
I have experienced this issue multiple times with different packages. For example, LangChain had the same problem which I described here: langchain-ai/langchainjs#4060 (comment)

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:

2024-05-08_09-04-41.mp4

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!

@zirkelc zirkelc added the bug Something isn't working label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant