-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
VSCode's auto import not suggesting packages since typescript: "4.2.1-rc"
#56166
Comments
Why your repo doesn't have |
@IllusionMH Good catch, I kind of forgot about it since it didn't make a difference. I added a generic one (generated via TLDR: Added |
Symbols can only be auto-imported when the relevant project is "in your project", i.e. has been imported at least once already (either directly or indirectly). This changed as a result of a needed performance improvement, since some packages ship way too many / too large .d.ts files and aren't needed from code. |
I'm not sure I fully understand. Can this optimization be disabled? For context: |
There's a cutoff of 10 dependencies, again for performance. You can check the TS Server log which has a fairly verbose output of what auto-import is doing and why. There are a bunch of ways to get these files into your program for analysis purposes; a file importing the ones you explicitly want auto-import for is certainly one of them and probably the easiest to reason about. |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
many permutations of the following keywords:
vscode, intellisense, auto, import, typescript, typescript language server, tsconfig, node_modules
Also explicitly scanned the FAQ for "import".
🕗 Version & Regression Information
This changed in commit or PR _______no idea how to test thisThis is the behavior in every version I tried, and I reviewed the FAQ for entries about _________I was unable to test this on prior versions because _______⏯ Playground Link
https://codesandbox.io/s/demo-fail-imports-kwrxd6?file=/main.ts
💻 Code
The broken behavior can be demonstrated with the codesandbox link. However, the correct behavior can only be demonstrated by cloning this repository:
https://github.com/ciriousjoker/demo_fail_imports
The code is the same, but codesandbox.io doesn't support switching between typescript versions and other solutions like stackblitz don't support auto imports at all. Again, remember to restart the TS server between Typescript version switches.
🙁 Actual behavior
Import isn't suggested.
🙂 Expected behavior
Import should be suggested.
Additional information about the issue
npm install
isn't even necessary, just altering thepackage.json
triggers an "update" in this regard)I'm aware that typescript has some magic sauce to determine when to load type definitions, ie the "you have to import it once for Typescript to find it". However, I believe that with this minimal reproducible sample repo this (in my opinion) bug might be fixed.
The text was updated successfully, but these errors were encountered: