vscode typescript: 'Add all missing imports' shortcut

I think vscode now has this feature built in.

The shortcut Ctrl + . gives us options to autofix issues. I found this working even in case of multiple imports and all.

Please let me know if there is any other way to do the same :)


Is there a shortcut for the same?

Yes, coming in v1.46 (see v1.46 release notes: add missing imports source action):

Add all missing imports source action

VS Code has long supported a quick fix that adds all missing imports in a JavaScript or TypeScript file. This iteration, we introduced a new Add all missing imports source action lets you trigger this from anywhere in a file.

This also allows you to set up a keybinding for Add all missing imports:

{
    "key": "ctrl+shift+i",
    "command": "editor.action.sourceAction",
    "args": {
        "kind": "source.addMissingImports",
        "apply": "first"
    }
}

Or even enable Add all missing imports on save:

"editor.codeActionsOnSave": [
    "source.addMissingImports"
]