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

🐛 Unused export * from "./b" line not reported #842

Open
6 tasks done
guillaumebrunerie opened this issue Nov 21, 2024 · 1 comment
Open
6 tasks done

🐛 Unused export * from "./b" line not reported #842

guillaumebrunerie opened this issue Nov 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@guillaumebrunerie
Copy link

Prerequisites

Reproduction url

https://codesandbox.io/p/devbox/wp5lv3

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

I found a situation in which an export * from "./b"; line is unused (removing it makes no difference), but Knip doesn’t report anything:

// a.ts
export const a = "a";

// b.ts
export const b = "b";

// aAndB.ts
export * from "./a";
export * from "./b"; // Unused line?

// index.ts
import { a } from "./aAndB";
import { b } from "./b";
console.log(a, b);

Note that both a and b are used, but b is imported directly rather than being imported from the barrel file. This is a sign of a potential issue, that maybe b was meant to be imported from aAndB instead.

It’s not a big issue, as there isn’t any actual code that is unused (except from the export * line which will most likely disappear after bundling anyway), and supporting this use case would maybe require a whole new category of things that can be potentially unused, but I felt like I should report it anyway if you feel like it should be fixed.

@guillaumebrunerie guillaumebrunerie added the bug Something isn't working label Nov 21, 2024
@webpro
Copy link
Collaborator

webpro commented Nov 21, 2024

Oh, interesting. It's simply not supported yet, but I guess it could be. Won't be trivial at first thought though, because that * in the barrel file is not an exporteded identifier (yet).

Edit: and the * is also often not unique either (like in the example).

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