-
Notifications
You must be signed in to change notification settings - Fork 137
TypeScript source files in "types" exports can cause compilation errors (npm) #446
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
Comments
Oh this is not intentional - do you have an example where this is happening? It should not point to |
I noticed it when installing the package @noble/secp256k1. The contents of https://npm.jsr.io/~/8/@jsr/noble__secp256k1/2.1.0.tgz are:
and package.json looks like this: {
"name": "@jsr/noble__secp256k1",
"version": "2.1.0",
"homepage": "https://jsr.io/@noble/secp256k1",
"type": "module",
"dependencies": {},
"exports": {
".": {
"types": "./index.ts",
"default": "./index.js"
}
},
"_jsr_revision": 8
} |
Wow, this explains a lot! I have been fighting with this issue for several days. Source files of JSR packages are getting type-checked.
|
Great - thanks. I'll get this fixed today |
I can reproduce - this happens for packages that are using slow types, so where no |
This was happening for packages that had slow types. Fixes #446
I'm still struggling with it. Not sure if it's my fault. The package does not have slow types. In If I delete My bundler (Vite) is trying to load the .ts source file for some reason. |
It will be working tomorrow - there is one more PR that needs to land (#463), and then all the tarballs will be regenerated in the background over the course of tomomrrow - I'll let you know once it's actually fixed in prod :) |
@alexgleason This is now fixed. Remove your lockfile and re-run |
It works now. Thank you @lucacasonato !! 🚀 |
In #377 the package.json files for npm where changed so that the source .ts files are used for "types" exports instead of .d.ts files as was done previously. This is not right, because when such a package is installed and imported in a TypeScript file, TypeScript will try to compile the dependency source file with the project's compilation settings, which may be different and cause compilation errors, for example, due to different settings for
noUncheckedIndexedAccess
.The original issue #313 that was marked as fixed proposed adding declaration maps and source files in addition to the compiled .d.ts files that go in "types" exports. This allows "go to definition" to work as expected, and does not cause the compilation errors that the current approach causes.
The text was updated successfully, but these errors were encountered: