-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Package exports field does not include types #18835
Comments
Some additional content: |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
lol 😂 |
…on (#27152) We currently rely on the TS behavior of matching `d.ts` files based on the `.js` file names. e.g. `foo.js` matches `foo.d.ts`. However, it isn't working for all tools so we should explicitly set it. Most modern packages are still setting it even though it is not technically needed. e.g. [Nuxt](https://unpkg.com/browse/[email protected]/package.json) Note: If both ESM and CJS are present, then prefer `*.esm.d.ts` files since the generated types are in ESM format. ## Current Behavior `exports` entries are missing `types` field ## Expected Behavior `exports` entries have `types` field set ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18835 (cherry picked from commit 2d2c0b5)
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
I have a React library that has multiple additional entrypoints and generates and exports field. When I build it the package.json exports field does not include a typings field to reference the .d.ts files that have been generated. As a result, when the library is published to NPM, and I try to consume it I get TypeScript errors as it cannot find the types for the library.
Here is an example of the output:
Note the types only gets added to the top level of the package.json, not each export.
Expected Behavior
When generating exports fields the types would be added to package.json correctly, e.g.
GitHub Repo
No response
Steps to Reproduce
Follow the steps as outlined in Juri's helpful tweet 😊:
https://twitter.com/juristr/status/1692537684659785802
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: