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

auto import not working properly #35792

Closed
Tahir500 opened this issue Dec 18, 2019 · 10 comments
Closed

auto import not working properly #35792

Tahir500 opened this issue Dec 18, 2019 · 10 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@Tahir500
Copy link

Issue Type: Bug

auto import is not working in the new udpate, it was working in the previous build

VS Code version: Code 1.41.0 (9579eda04fdb3a9bba2750f15193e5fafe16b959, 2019-12-11T17:59:52.065Z)
OS version: Windows_NT ia32 10.0.18363

here is a short video on that
https://drive.google.com/file/d/1inQ1yZGLSfxeXmGLcDl81nEsATyTrjik/view

image

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 1992)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.90GB (5.95GB free)
Process Argv
Screen Reader no
VM 67%
Extensions (5)
Extension Author (truncated) Version
vscode-apollo apo 1.12.2
gitlens eam 10.2.0
prettier-vscode esb 3.16.1
python ms- 2019.11.50794
vscode-import-cost wix 2.12.0
@IllusionMH
Copy link
Contributor

/needsMoreInfo

Please provide more in info about language, your configuration, code that causes problemts etc.

If you are using TS/JS and expecting to see packages that aren't in your package.json it intentional #32517 and duplicate of #35560

@vscodebot
Copy link

vscodebot bot commented Dec 18, 2019

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

@SantoJambit
Copy link

I have this issue as well. I try to import a type, which a package supplies, but it doesn't appear in the suggestions. The package is defined in the package.json as devDependency.

TypeScript 3.7.3 (Also tried Nightly with same result) on Ubuntu 18.04.

I've noticed this not working on multiple occasions with different packages. Some packages work, others don't. Not sure if there is anything with caching going on here.

@Tahir500
Copy link
Author

@IllusionMH i have created a video on that. please have a look
https://drive.google.com/file/d/1inQ1yZGLSfxeXmGLcDl81nEsATyTrjik/view
i am not getting any suggestion when pressing Ctrl+space, also Go to definition is not working

@SantoJambit
Copy link

For me it's a bit different:

  • local imports work fine
  • import from a dependency will not be suggested.
  • Once I manually write the import statement, I can go to definition just fine
  • Once I manually write the import statement for at least one type, I can even auto-import other types/methods from that dependency.
  • However, after removing that import statement again, auto-import suggestions are gone again.

@Jeddus
Copy link

Jeddus commented Dec 18, 2019

I had the same problem since the update to VSC 1.41.0. In my case, it seams that the latest Typescript version (3.7.3) is causing the import problems.

I resolved it by using an anterior TS version. I used the Typescript Workspace version (mine is 3.5.3) instead of VS Code's version (3.7.3). You can see/set it at the bottom-right of the VSC editor.

Hope it can help.

@IllusionMH
Copy link
Contributor

@SantoJambit looks it functions as designed in your case if "import from a dependency will not be suggested." is about dependency that is not in your package.json since auto-imports from packages in 3.7 only show suggestions for direct dependencies (see #32517)
If this package is in your package.json but not in suggestions - please create new issue.

As soon as you manually add import to your file - you add this module to your project tree and it will be treated as usually with auto-import functionality.


@Tahir500 do you see "Initializing JS/TS language features" in the status bar after commenting out import and requesting suggestion? Looks like TS takes too much time to process updated project tree or hangs/crashes in process.

To understand what goes wrong more info about project structure will be useful (or link to repo if it's in open access).
It will be also useful to know if there are nay errors in DevTools and TS Server logs (please note that tsserver.log contains path to files on your disk and you might need to redact it before sharing)

/cc @andrewbranch

@lanpong
Copy link

lanpong commented Dec 19, 2019

@IllusionMH i have created a video on that. please have a look
https://drive.google.com/file/d/1inQ1yZGLSfxeXmGLcDl81nEsATyTrjik/view
i am not getting any suggestion when pressing Ctrl+space, also Go to definition is not working

Oh, I found delete node_modules folder, and reinstall node_modules later, it working, you can try it

update:
it just working once, reopen workspace, it not working

update again:
I delete node_modules/@types folder, it working

@mjbvz mjbvz transferred this issue from microsoft/vscode Dec 20, 2019
@mjbvz mjbvz removed their assignment Dec 20, 2019
@microsoft microsoft deleted a comment from vscodebot bot Dec 20, 2019
@mjbvz mjbvz self-assigned this Dec 20, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Dec 20, 2019

@Tahir500 Please share repo steps and code as text in addition to the videos

@SantoJambit
Copy link

SantoJambit commented Jan 3, 2020

@IllusionMH I am talking about direct dependencies. But I just tried using an older TS version with the same result, so maybe this is a vscode issue and not a typescript issue.

Edit: It seems my issue is @types vs bundled types, as described here: https://github.com/microsoft/vscode/issues/88015

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Jan 7, 2020
@mjbvz mjbvz removed their assignment Jan 21, 2020
@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

7 participants