Reputation: 113
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.
Upvotes: 8
Views: 32446
Reputation: 834
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!
Upvotes: 2
Reputation: 323
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.
Upvotes: 1