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

Specify type definitions for tsc node12 imports #20

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

willstott101
Copy link
Contributor

In tsc nightly a new module resolutions scheme is introduced called node12 or nodenext which uses this "exports" field in package.json files. When this is present and being used then the old root "types" is not used. You have to specify the types in the specific exports (when the files are not adjacent).

@lukeed
Copy link
Owner

lukeed commented Mar 11, 2022

There's no reason for this in this module. The existing layout and pkg config has all entries loading with their correct types

@willstott101
Copy link
Contributor Author

Have you had it loading properly with typescript@next and node12 module resolution set in tsconfig? Because it failed to find types for me with that setup... unless I added these lines. I'm happy to make an MCVE if you like, or find the GitHub thread on tsc that I was reading which led me to realise this is what I needed to add.

@willstott101
Copy link
Contributor Author

Just the clarify the node12 name may sound like it's old - but the full resolution scheme isn't even fully released in tsc yet. Support for package.json's exports field is very young in tsc it seems.

@willstott101
Copy link
Contributor Author

@chocolateboy
Copy link

chocolateboy commented Jul 10, 2022

Can confirm the declaration file isn't getting found for me without this on TypeScript 4.8-beta with moduleResolution set to nodenext.

(That said, I'm not sure why tsc doesn't just fall back to the top-level "types" field if all else fails, or add an option (e.g. esmcompat) to do that.)

package.json Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

3 participants