Unused exported type & interface members
This PR introduces --include typeMembers to find unused members of exported types and interfaces.
Docs: https://feat-unused-exported-type-me.knip.pages.dev/guides/type-members.
See below to install latest version through pkg.pr.new.
Dogfooded knip --include typeMembers --fix: 2b019931085da943b3db9725fbfec64b21c5b42a
WIP. From: https://github.com/webpro-nl/knip/pull/848#issuecomment-2585735560
TODO:
- [x] Improve docs and explain better what members exactly are and are not analyzed
- [x] Remove members with
--fix - [ ] Mileage
Deploying knip with
Cloudflare Pages
| Latest commit: |
897448b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a557c772.knip.pages.dev |
| Branch Preview URL: | https://feat-unused-exported-type-me.knip.pages.dev |
This sounds like a helpful thing to warn on.
At the same time, it seems perfectly valid to have unused type members for things like the result of an external REST api request. I'd type out all members of the expected response and maybe not use all of the fields at first.
Iteration speed is definitely a thing to consider, yet could be mitigated using local JSDoc tags or config e.g. ignore: ["src/{api,generated}/**"] to (temporarily) exclude files or parts of the codebase. But won't suit everyone, takes a little bit of extra work/config. In the end the issue type is opt-in to begin with.
There are still bugs atm, but mostly closing due to added scope/complexity.