Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Code : How to detect dead typescript code

There are tslint rules available for private method. But How can I find out if the public method is not used anywhere in the project and hence candidate for the dead code. I am using Visual studio code for Typescript.

like image 271
Pramod Avatar asked May 05 '18 00:05

Pramod


People also ask

How do I find the unused code in VSCode?

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).

How do you find the dead code?

The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.


1 Answers

Have a look to https://www.npmjs.com/package/ts-unused-exports

It produces an output like this

$ ts-unused-exports tsconfig.json

4 modules with unused exports

src/lambda: handler
src/routes/crud: default
like image 116
bitIO Avatar answered Oct 24 '22 21:10

bitIO