-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Possible false positive bug with destructured named exports #1
Comments
Interesting, maybe you could take a stab at a PR? |
Probably a destructured variable export hasn't been accounted for near here: find-unused-exports/private/scanModuleCode.js Lines 111 to 118 in 3208426
|
Also, what about array destructuring? E.g. something like: export const [a] = [true]; |
Also, need to account for this: export const { a, b: c } = { a: true, b: true }; |
What about this: export const [, a] = [true, true]; Edit: So I tested the above in Node.js, using: import * as a from './a.mjs';
console.log(a); And the result was |
Holy cow! Just released this needs to be a recursive operation as the destructuring can be arbitrarily deep/complex: export const { k, l: { m: [n]} } = { k: true, l: { m: [true] } }; In that case the named exports are |
Also, spread syntax: export const { a, ...b } = { a: true, b: true, c: true };
export const [, ...c] = [1, 2]; |
The fix has been published in v1.1.1 🚀 |
Reproduction: https://github.com/dburles/find-unused-exports-issue
I found that exporting named exports in this way results in a false positive with no exports named:
The text was updated successfully, but these errors were encountered: