简体   繁体   中英

Detect unused methods - Visual Studio Code

Is there a way to detect unused methods in a typescript file (Angular) in Visual Studio Code? I've tried a couple of plugins for Angular but in vain. Web Storm used to grey out the unused methods by default. Looking for a similar thing in VS Code.

Hi You can try to run your application with " ng serve --aot " cli command instead of " ng serve " , it shows you a whole number of these unused codes(like when you leave " ng build --prod " command).

Or you can try this method but I'm not shure of this:

https://alexjover.com/blog/tree-shaking-with-webpack-2-typescript-and-babel/

Hope it will work!

It is currently not possible to detect unused public methods in VSCode (you can check for updates here ). However, if it's a private method, you can mark it as private and VSCode is able to look for whether it is used or not within the scope (although do remember: methods used in the HTML template are public).

If the public method checks are important for you, you'll have to either wait, or contribute to the VSCode community. I still use VSCode but if it is a necessity for you, just switch to WebStorm for the moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM