typescript – Visual Studio Code Automatic Imports

typescript – Visual Studio Code Automatic Imports

2018 now. You dont 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:

enter

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

enter

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 doesnt always work.

List of Plugins

Screenshot of Extensions

screenshot
*click for full resolution

typescript – Visual Studio Code Automatic Imports

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.

Leave a Reply

Your email address will not be published.