Report unused re-exports when ignoreExportsUsedInFile is set#1895
Merged
webpro merged 3 commits intoJul 21, 2026
Conversation
6 tasks
Member
|
The |
Contributor
Author
|
Yep I can confirm that it work. Ran my original repro against d648f41, both Dead sites get reported now and |
commit: |
Member
|
Thanks! These are real findings now: https://github.com/webpro-nl/knip/actions/runs/29754772364/job/88631556813?pr=1895 |
Member
|
🚀 This pull request is included in v6.28.0. See Release 6.28.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1894
With
ignoreExportsUsedInFileset, re-exports were always treated as used in their own file and never reported. A re-export likeexport type { Dead } from './schemas'has no local binding, so it cannot actually be used in its own file. When the source export was unused,--fixremoved theexportkeyword at the declaration but left the re-export behind, and the project no longer compiled.This removes the blanket
isReExportcheck, so re-exports get the same local reference check as other exports. Theimport { X }plusexport { X }case keeps working, since usage ofXin the file is picked up by that check (covered by the existingre-exportfixture).The expected count in
test/re-exports/ignore-exports-used-in-file.test.tsgoes from 1 to 2: the unused export is now also reported at the re-export site, same as withoutignoreExportsUsedInFile. That test was added for #698 to make sure the export is reported at all, so this stays in line with its intent.