-
Notifications
You must be signed in to change notification settings - Fork 12.8k
There are some issues about Auto Import feature in VSCode builtin expension. #31763
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
@RyanCavanaugh I believe this is the same issue as #30033 (comment) Since we keep seeing this issue being reported, is there some way we could look into improving the user experience? Maybe eagerly allowing auto imports from any package explicitly listed in the |
Seems to be a duplicate of #31676 It's just a matter of time before more *.d.ts declaration files get corrupted. |
This is about auto-imports in VSCode, that other thing is about declaration file generation which doesn’t sound related at all? |
not relate at all. |
Sorry, my bad. The effect of #31676 is that imports suggested by vscode are "not working". That's why I jumped to conclusions. |
The more consistent feedback I hear from VS Code is that people want things to be fast, and this is certainly something that will make things slower. Auto-import is a best-effort feature (it's impossible for us to exhaustively list every possible correct import path) and the behavior we have here lights up as expected after the first import in any location. |
Actually, unless I am misunderstanding the issue, it does seem like there is a bug with lodash auto imports. Even after adding an import, I don't get auto import suggestions for many functions repo
Bug |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
This is happening to me also on my current project. Funny thing is, when I created a new react project based on typescript(that uses .tsx extension only) using CRA, it didn't happen. |
TL;DR
Ok, so there are three things happening here.
Yep, because these are defined in local (non-node_modules) files, so they’re eagerly loaded into your program by default.
These work because React doesn’t ship their own types, so
Ok, this is where it gets interesting, because the reason each of these doesn’t work right away is different. One by one, in reverse order:
Yep! This one is expected behavior, and is another instance of #30033. Because @material-ui/core ships its own types, the type definitions are in
This one is a TypeScript bug that only comes up for JavaScript users, tracked specifically by #33289.
Ah, so this one is actually due to the way lodash has written their typings on DefinitelyTyped. When you Given that these are now all tracked by separate specific issues, I’m going to go ahead and mark as duplicate so this one mega-issue can be closed. Thanks @guohuamin for the very detailed report 🌟 |
Re lodash typings: one of the maintainers points out that if you’re using a compatible build system, you can use |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
I have another problem,, |
@AbuDawood please open a new issue with repro steps, TypeScript version, etc. |
Yes @andrewbranch I did, in #35926
|
That's not wrong, without extension is only supported with tools, officially you need to add the extension (it even was .mjs for modules but no-one uses that). I'm programming clean vanilla js and was annoyed it left the extension out on the 1st import it created. Apparently it looks at the rest of the imports and adopts which is fine and smart. Don't know why you got the opposite result. |
Issue Type: Bug
Hi, VSCode Team! I'm a deaf disable chinese. When I try to use the Auto Import feature in VSCode builtin expension(Typescript and Javascript Feature), I found that the suggestion list don't show a lot of variables that can add automationally import statement at the top of the file,but from these dependencies that I need to import auto. I show this sample..
In the sample project structure,
test[project-directory]
--node_module
--src
----lib
------fun.js
----app.js
----jsconfig.json
--package.json
In package.json file,
In jsconfig.json file,
In src/lib/fun.js file,
In src/app.js file:
This file is emtry file, I start to try to type "add" or "mul" , it can show these variables that can import auto. because in src directory has jsconfig.json file, it tell VSCode that this src directory is served as javascript project. I have four deps (react, react-router-dom, lodash, @material-ui/core) that I need to reference variables with auto import feature from. If I want to reference "Component", "useState" or "useEffect" from React library dep, when I try to type "Com.." or "use..", I foud that auto import can work. But, if I want to reference some variable from 'lodash','react-router-dom' and '@material-ui/core', and I try typing some suffix word, I found that the auto import doesnt' work! Atfer I first add "import {} from '@material-ui/core'", I try to type "Button" or "Paper", the result in that auto import feature help me to write "Button, Paper" in the { } curly in "@material-ui/core".In other 'lodash' or 'react-router-dom' deps, I try to type 'range' or 'random', 'Link', "Route", the result in the auto import doesn't work! These four deps have the typing file(.d.ts) from Automatic Type Acquisition. These are trouble! How to solve these problems? Thanks you!
VS Code version: Code - Insiders 1.35.0-insider (0284236, 2019-05-31T21:32:42.295Z)
OS version: Windows_NT x64 10.0.18898
Remote OS version: Linux x64 4.4.0-18898-Microsoft
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (10)
(1 theme extensions excluded)
The text was updated successfully, but these errors were encountered: