A few months back I posted a Show HN to share my idea about removing unused code in TypeScript projects automatically by statically analyzing the codebase: https://news.ycombinator.com/item?id=41554014
I didn't expect much response but the post gained a lot of feedback and controversy mostly due to how rough-edged the tool was. Since then, I've been working on polishing the tool and I've managed to release v1 with a new name "tsr" so I'd like to share it here.
Here are the key features:
- it supports comprehensive auto-editing: not only does it remove unused export keywords, it can remove declarations that become unnecessary after removing the export keyword
- small: 234kB compared to 5.8MB with Knip
- fast: Benchmarks with the vuejs/core repository shows that it's 2.5x faster compared to Knip.
Internally, I've written some custom logic since then to traverse the files and detect the usage of declarations instead of relying on ts.LanguageService.findReferences (which Knip also uses) to avoid limitations caused by this API and for more performant results.
kazushisan|1 year ago
I didn't expect much response but the post gained a lot of feedback and controversy mostly due to how rough-edged the tool was. Since then, I've been working on polishing the tool and I've managed to release v1 with a new name "tsr" so I'd like to share it here.
Here are the key features: - it supports comprehensive auto-editing: not only does it remove unused export keywords, it can remove declarations that become unnecessary after removing the export keyword - small: 234kB compared to 5.8MB with Knip - fast: Benchmarks with the vuejs/core repository shows that it's 2.5x faster compared to Knip.
Internally, I've written some custom logic since then to traverse the files and detect the usage of declarations instead of relying on ts.LanguageService.findReferences (which Knip also uses) to avoid limitations caused by this API and for more performant results.
Any feedback is very much appreciated!