Devin
Devin

Reputation: 1992

Removing unused imports in AngularJS project in bulk using Visual Studio Code

I'm tasked with cleaning our AngularJS project to remove unused imports and variables. I use VS Code and through TypeScript Hero extension I can do what I want to do one file at a time. However, is there a way to fix all typescript files in project?

Upvotes: 7

Views: 3516

Answers (1)

JayKan
JayKan

Reputation: 4865

For visual studio code, you can simply open your preference settings and add the following to your settings.json:

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
  "source.organizeImports": true
}

You can also enable/disable on save per language using following setting.json:

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

This new feature has been released since April last year in 2018. Hopefully this can be helpful!

Upvotes: 7

Related Questions