Fix missing 'exports.types' field of package.json #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a recent project set up with Vite+Typescript, I installed threejs-math (
npm install threejs-math
) and imported some types:But I got the following Typescript errors in my IDE (Sublime Text 4 with LSP-Typescript plugin):
At first I thought it was probably a configuration problem of my project, my installation, or my IDE, but I couldn't fix it that way.
So following the suggestion of the error message, I looked online and found many projects having the same problem, which seems caused by the addition of new module resolution methods in recent versions of Typescript, see the following threads:
types
condition to thepackage.json#exports
gxmari007/vite-plugin-eslint#60The solution seems indeed to add the following to
threejs-math/package.json
:I tested this change and indeed it makes the error message go away in my case, and all types are now properly imported in my project.