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

🐛 TS4023 from removing reported unused export if exported type is referenced implicitly in another package #808

Closed
6 tasks done
aaayane opened this issue Oct 9, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@aaayane
Copy link

aaayane commented Oct 9, 2024

Prerequisites

Reproduction url

https://stackblitz.com/edit/github-a4rrlb-3x1iep?file=README.md

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

Hi, thanks for your work on this project. I think I have a similar problem which doesn't seem to be solved in the new version.(knip 5.33.2).
from https://github.com/webpro-nl/knip/issues/801

When exporting a function, the reference type will still prompt that it is not used

Reproduction url
https://stackblitz.com/edit/github-a4rrlb-3x1iep?file=README.md

Description of the issue
When exporting a function, the reference type will still prompt that it is not used
TS4023: Exported variable 'sharedFunction' has or is using name 'Error1' from external module "/home/projects/github-a4rrlb/packages/shared/src/file2" but cannot be named.

See the readme of the linked reproduction for exactly how this can happen

@aaayane aaayane added the bug Something isn't working label Oct 9, 2024
@webpro
Copy link
Collaborator

webpro commented Oct 9, 2024

Thanks for the report, @aaayane! Could you please try with this one:

npm i -D https://pkg.pr.new/knip@1c04163

Happy to know if this works better for you!

@aaayane
Copy link
Author

aaayane commented Oct 10, 2024

#801

Looks like this has been resolved, thanks for your work!

@aaayane
Copy link
Author

aaayane commented Oct 10, 2024

#801

Looks like this has been resolved, thanks for your work!

@webpro By the way, I may have found another problem

Reproduction url

https://stackblitz.com/edit/github-a4rrlb-7fzqsb?file=README.md,packages%2Fshared%2Fsrc%2Ffile2.ts

Description of the issue

When I export destructuring assignment, using fix will mistakenly delete the variable being used

When I wrote the example, I found that using npm only prompts unused exports, but using pnpm will delete the definition of a.

I don’t know what the difference is between the two. It seems that there is an error when using pnpm。

See the readme of the linked reproduction for exactly how this can happen

@webpro
Copy link
Collaborator

webpro commented Oct 10, 2024

Thanks @aaayane! Very happy with your feedback. Things should be better now here:

npm i -D https://pkg.pr.new/knip@307ef8d

Ideally, the export keyword is removed when there are no exported elements left, but that'll come later. At least the referenced exported element is no longer removed.

@aaayane
Copy link
Author

aaayane commented Oct 10, 2024

Thanks @aaayane! Very happy with your feedback. Things should be better now here:

npm i -D https://pkg.pr.new/knip@307ef8d

Ideally, the export keyword is removed when there are no exported elements left, but that'll come later. At least the referenced exported element is no longer removed.

it's worked, , thanks for your work, this project is great and solved my problem

@webpro
Copy link
Collaborator

webpro commented Oct 10, 2024

Nice! The implementation is something I need to clean up, and removing the export keyword for such empty bound declarations is on my list to do. But I'm very glad we got this sorted for now.

@webpro webpro closed this as completed in 3dd6cfd Oct 10, 2024
@webpro
Copy link
Collaborator

webpro commented Oct 10, 2024

🚀 This issue has been resolved in v5.33.3. See Release 5.33.3 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