Visual Studio Code Automatic Imports
2018 now. You don't need any extensions for auto-imports in Javascript (as long as you have checkjs: true
in your jsconfig.json
file) and TypeScript.
There are two types of auto imports: the add missing import quick fix which shows up as a lightbulb on errors:
And the auto import suggestions. These show up a suggestion items as you type. Or you can select text and press Ctrl + Space to bring up a list of suggestions. Accepting an auto import suggestion automatically adds the import at the top of the file
Both should work out of the box with JavaScript and TypeScript. If auto imports still do not work for you, please open an issue
I got this working by installing the various plugins below.
Most of the time things just import by themselves as soon as I type the class name. Alternatively, a lightbulb appears that you can click on. Or you can push F1, and type "import..." and there are various options there too. I kinda use all of them. Also F1 Implement for implementing an interface is helpful, but doesn't always work.
List of Plugins
- npm Intellisense
- ngrx for Angular 2 Snippets
- TypeScript Toolbox
- npm
- TsTools
- Angular Snippets (Version 9)
- Types auto installer
- Debugger for Chrome
- TypeScript Importer
- TypeScript Hero
- vscode-icons
- Add Angular Files
Screenshot of Extensions
*click for full resolution
I used Auto Import plugin by steoates which is quite easy.
Automatically finds, parses and provides code actions and code completion for all available imports. Works with Typescript and TSX.