Search code examples
visual-studiotypescript

How to invoke the "Organize imports" TypeScript feature in Visual Studio?


There is a new feature in TypeScript 2.8 that lets you "Organize imports": https://devblogs.microsoft.com/typescript/announcing-typescript-2-8-2/#organize-imports

Basically it does the following:

  • remove unnecessary import statements
  • sort the import statements

The page shows that the feature can be invoked in Visual Studio Code with the Shift+Alt+O keyboard shortcut. Does anybody know how this feature can be invoked in Visual Studio (2017)?

UPDATE:

From version 15.8 onward Visual Studio 2017 highlights unused imports by greying them out.


Solution

  • This feature has now been added to Visual Studio 2017.

    One can invoke it the following ways:

    1. Pressing Ctrl+R followed by Ctrl+G.
    2. Right-click in the code window and click Organize Imports in the context menu.