ts-prune icon indicating copy to clipboard operation
ts-prune copied to clipboard

[Feature] Avoid false positives

Open a7madgamal opened this issue 2 years ago • 0 comments

I noticed that many of the results are false or missleading

To Reproduce please check this repo https://github.com/a7madgamal/ts-prune-bug and run npm run find-deadcode

Current result:

src/components/index.ts:4 - Button (used in module)
src/components/index.ts:4 - Dead (used in module)
src/components/dead/dead.ts:2 - SuperDead

I want to exclude or differentiate the result Button. It's exported twice, once from the Button file itself and again from index.ts (a very common practice, usually with * from xxx so it's not possible to exclude something exported needlessly through this star) Although the export from index.ts is useless it's still not dead-code because it's being imported from button.ts directly

Expected behavior The expected behaviour can be one of 2 options IMO: 1 - indicate this case in the results like this:

src/components/index.ts:4 - Button (⚠️ export here not needed, but used through other exports)
src/components/index.ts:4 - Dead (⚠️ export here not needed, no other exports detected)
src/components/dead/dead.ts:2 - SuperDead (🔥 kill it with fire)

2- support an option to show only completely unused exports

Optional: reference to the test project https://github.com/a7madgamal/ts-prune-bug

a7madgamal avatar Sep 20 '22 13:09 a7madgamal