-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 False positive on Unused exported enum members when used with Object.values #927
Comments
This needs to be documented better, but currently it's expected behavior. If I'm not mistaken it currently works just like namespace imports (https://knip.dev/guides/namespace-imports), i.e. if there's even just a single explicit "property access" like In the case of namespace imports we can disable that behavior (and have Knip always track all individual exports by including the I guess ideally there'd be three modes:
Happy to hear thoughts on this if you have any. What you could already use is |
I forgot to mention this behavior was added/changed with fc5982e (in the latest release 5.43.3). I guess my thoughts on this are rather simple as I am far from deep into this topic or similar ones regarding knip. In my opinion knip should be as precise as possible. Since |
I see. I think the behavior you expect by default makes sense. Still I'd like to offer the option to have Knip report unused members regardless of implicit member iteration/usage. Also I don't like breaking changes so I'll work something out :) |
Sounds more than fair to me. It's always good to have knobs to individualize things 👌🏻
Neither do I. Especially not in a patch version release - hence my report 😬 |
Turns out, was basically a missing test I still had stashed. |
🚀 This issue has been resolved in v5.43.4. See Release 5.43.4 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
A fix in two parts, really. Things should be alright in v5.43.5. |
Pipeline is green again ✅ Thanks for these fast responses, awesome job @webpro |
Thanks for the report! That's a win-win. |
Prerequisites
Reproduction url
https://codesandbox.io/p/devbox/r3m3jy
Reproduction access
Description of the issue
Knip is reporting
Unused exported enum members
when an enum is used inObject.values
and not all of the members are explicitly used somewhere else.In the repo knip reports
Test.SECOND
to be unused, because it is only implicitly used inObject.values
whileTest.FIRST
is fine, because it is explicitly used.The text was updated successfully, but these errors were encountered: