Reputation: 480
I am having trouble with auto importing node_modules
in angular, vsCode
Expected behaviour: When i start typing a name of an installed module in my angular typescript files, for instance "MatMenuM" or "HttpCl", a suggestion for an import should appear.
Current behaviour: The correct suggestion does not appear
My environment: Fresh angular project on windows 10 with newest(28.03.2022) versions of angular cli, node, typescript, vsCode, only two extensions, all up-to-date, and imported newest angular material.
I realize that this question has been asked a couple of times, but none of the answers solve my problem. Also the angular and ts versions might be different. I will link all related questions below. I also tried all of the suggested solutions:
I tried:
typeRoots
in my tsconfig.json
, as described here, all i got was this:Also this github issue related to the same problem sais the issue should be fixed with the new ts version... which it isn't for me.
setting my preferred pathstyle for auto imports to relative, shortest, project-relative and non-relative
uninstalling angular, node, vsCode and ts and reinstalling it
removing all extensions
removing types: []
from my tsconfig.app.json
adding "node_modules/@angular/**/*.d.ts"
to include in my tsconfig.app.json
Related questions: 1, 2, 3, 4, 5
Help will be much appreciated!
Edits: images not formatted correctly, spelling
Upvotes: 4
Views: 10711
Reputation: 480
Solved my problem:
VsCode does not autosuggest modules out of the box, even with older versions as far as i can tell. I was under the misconception that it did, since in my work project, suggestions work fine, however now i realize that was only because:
VsCode needs the module to be imported at least once (doesn't matter where) to suggest it everywhere.
So you have to import it once, then vsCode starts suggestions, which means only one time pain.
Still setting up a new project can be tedeous that way, i will use webstorm(suggests everything out of the box) as a setup IDE, then if my project as enough imports, i can still switch back to vsCode.
Upvotes: 12