Skip to content
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

Dynamic import with destructuring false positive on unused export #688

Closed
shawnmcknight opened this issue Jun 20, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@shawnmcknight
Copy link

I've created a simple reproduction at https://github.com/shawnmcknight/knip-dynamic-import-destructuring.

Dynamic imports of the signature import("./components.ts").then(({ Apple }) => Apple); are reported as unused exports while dynamic imports of the signature import("./components.ts").then((mod) => mod.Orange); are not reported as unused exports.

As illustrated in the reproduction, I have a components.ts file that is:

export const Apple = () => "Apple";
export const Orange = () => "Orange";

and an index.ts file that is:

import("./components.ts").then(({ Apple }) => Apple);
import("./components.ts").then((mod) => mod.Orange);

When running knip the output is:

Unused exports (1)                
Apple  unknown  components.ts:1:14

Please let me know if there is anything else I can provide to assist!

@shawnmcknight shawnmcknight added the bug Something isn't working label Jun 20, 2024
@webpro webpro closed this as completed in 1343826 Jun 21, 2024
@webpro
Copy link
Collaborator

webpro commented Jun 21, 2024

Thanks @shawnmcknight, great report + repro 🙏

@webpro
Copy link
Collaborator

webpro commented Jun 21, 2024

🚀 This issue has been resolved in v5.22.1. See Release 5.22.1 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants