-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Auto-imports offered from another package’s node_modules #45784
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
Happens to me as well. Downgraded to 1.59 for now (works fine there) |
@Kvek @danieldt232 Would either of you be able to provide a link to a repo where this is happening? Short of that, your dependencies/devDependencies and what package manager you’re using would help. |
@dgattey can you confirm that |
Looks as expected! Though we do have some types in the wrong section. Nothing off otherwise
|
Nope, still can’t reproduce 😞. @dgattey, when I install these packages with npm, neither
|
@andrewbranch Using yarn 1.22.11 on macOS on an M1 MBP, and here's the lock file! Will work on getting you read access during business hours tomorrow. https://www.dropbox.com/s/t0gd8dlpyz8420c/yarn.lock?dl=0 I got curious and looked at another project, similar setup but different packages and uses Gatsby instead of Next. I'm ALSO seeing Anyway, here's the TS Server log from project 1 (Next.js repo from before): And from project 2 (Gatsby repo): Dependencies for project 2 are:
|
Thanks for the quick fix @andrewbranch! |
My apologies @andrewbranch, a little late to the party. Unfortunately it's my company's repo, so it's private. I'm using node - v12.13.0;
|
Sorry, accidentally closed it. |
@Kvek, would you be willing to see if #45792 fixes it for you? You can install the packed TypeScript version there by following the instructions in @typescript-bot’s last message. Then, ensure VS Code is using that version by running |
@andrewbranch I manged to fix the issue by updating Thanks for the help tho, much appreciated 😄 |
I have the same issue, updating the |
Have the same issue, I've pinned the problem down to the current v4.4.x TypeScript version and posted a solution on stackoverflow to temporarily fix it while staying on the latest VSCode version, see here @andrewbranch I have tested the internal build you linked as well and that does seem to fix it for me. |
Just as a status update, the PR that fixes this is a definite improvement, but it leaves a few very strange edge cases unhandled. I’m hoping to improve it further, but either way, the issue will definitely be fixed for TS 4.5 RC, but is unlikely to be backported to a TS 4.4 patch. When this issue is closed, that means the fix will be in the next nightly release. |
Just want to add that this behavior breaks auto imports for Vue 3 as well (#46115) We have a re-export chain of What's worse is if we use a strict package manager like |
Hi I just wanted to add this in that I'm still receiving the same issue even on the insiders build with no extensions installed, the above image is from stable but when i install an older version of typescript its back to normal but selecting the built in vs code typescript it seems to pull the wrong types. I've tried updating all the project dependencies but that has no change. It seems to only be happening in the project I'm working on as a new create react app project seems fine. Update (Fixed I think): |
The fix is not in 4.4; it is in the nightly and will be in 4.5. You need to use |
Thanks for the reply Andrew yeah I've had it working since then now alright will await the update 😁 |
I'm still having this issue with 4.5, besides updating are there any other steps I need to take? |
@JulianKingman 4.5.what? It's not in 4.5 beta; it's in the nightly. |
I tried |
Installing |
@merobal are you 100% sure that VS Code is using TS 4.5.1-rc (see/click TypeScript in the status bar to find out)? I don’t know how this could be happening again after my fix. Unfortunately, to reproduce this, I basically need an exact copy of your node_modules. Can you share your npm/yarn lock file for this project? A repo I can clone would be a bonus. |
@andrewbranch right, VS Code used it's own version, TS 4.4.3. Using workspace version (4.5 RC) the bug is gone even with latest react types and works perfectly. |
😅 You scared me for a second. Thanks for checking! |
still got an error with error comes after reinstall node_modules without any updates |
|
Fixed by patching lockfile with resolutions to 17th react version. Because host-non-react-statics imports 18th @types/react. React-redux types did the same thing. Resolve all typings @types/react to 17th solve all problems. |
If you end up with two different copies of React typings in your program, you’re going to have a terrible time, and you need to fix it by fiddling with resolutions like you said. This issue is specifically about auto-imports coming from node_modules folders you don’t have direct access to. Errors like the one you encountered are 100% expected until you fix the resolutions. |
Resolve deps not a problem at all for me =) |
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
.tsx
file.useEffect | useRef | useState
The usual import path is
@types/react/index.d.ts
. It's now importing it from the file@types/react-transition-group/node_modules/@types/react/index
. The@types/react
option isn't event shown.Another thing I noticed is the path is displayed as
styled-jsx/node_modules/@types/react
but when I click into this file it takes me to@types/react-transition-group/node_modules/@types/react/index
, which has nothing to do with styled-jsx from what I can tell.This is such a weird issue. It was working yesterday, but now it suddenly popped out of nowhere. Any help is much appreciated.
The text was updated successfully, but these errors were encountered: