For finding "dead" code in a typescript project, I use package:
yarn add -D ts-prune
after installation, add a script to package.json
file:
{
...
"scripts": {
"find-deadcode": "ts-prune"
}
}
now use yarn find-deadcode
it will find and shows all unused exports in a project
The script above will detect unused exports, even if they are used internally within the module. So you can remove export
to make this code local only, or you can modify script to ignore this behavior:
{
...
"scripts": {
"find-deadcode": "ts-prune | grep -v '(used in module)'"
}
}
Top comments (0)