Is there a way to remove unused imports and declarations from Angular 2+?

后端 未结 7 632
长发绾君心
长发绾君心 2020-12-07 08:30

I\'m assigned to take some messed code from other developers who have already left the company recently.

I am curiously asking is there some plug-in of Visual Studio

7条回答
  •  醉梦人生
    2020-12-07 09:07

    To be able to detect unused imports, code or variables, make sure you have this options in tsconfig.json file

    "compilerOptions": {
        "noUnusedLocals": true,
        "noUnusedParameters": true
    }
    

    have the typescript compiler installed, ifnot install it with:

    npm install -g typescript
    

    and the tslint extension installed in Vcode, this worked for me, but after enabling I notice an increase amount of CPU usage, specially on big projects.

    I would also recomend using typescript hero extension for organizing your imports.

提交回复
热议问题