Loading episodes…
0:00 0:00

VS Code: Automatically Organize TypeScript Imports

00:00
BACK TO HOME

VS Code: Automatically Organize TypeScript Imports

10xTeam September 06, 2020 1 min read

In this quick tip, we’ll see how to configure VS Code to automatically organize TypeScript imports upon saving your source code files.

VS Code allows you to remove any unused TypeScript imports, sort existing imports by name and file paths.

VS Code: Automatically Organize TypeScript Imports

You can configure VS Code automatically organize TypeScript imports by following these simple steps.

First, open the settings using ⇧⌘P or Ctrl+Shift+P, search for Preferences: Configure Language Specific Settings... Press Enter on your keyboard then search for TypeScript. This will open the settings.json file where you need to simply add the following settings:

"[typescript]": {
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
},
"[typescriptreact]": {
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
}

This instructs VS Code to automatically organize TypeScript imports when saving the .ts and .tsx files.


Join the 10xdev Community

Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.

Audio Interrupted

We lost the audio stream. Retry with shorter sentences?