webpro-nl/knip

๐Ÿ”„ Unused exported types not being reported when consumed in the same file

adamrutherfordshaw opened this issue ยท 4 comments

Prerequisites

Reproduction url

https://stackblitz.com/edit/github-ckjg6m?file=README.md

Reproduction access

  • I've made sure the reproduction is publicly accessible

Good version

5.31.0

Bad version

5.32.0 onwards

Description of the regression

Unused exports of types that are used in the same file are no longer reported. However, other unused exports not used in the same file continue to be reported as expected.

The behaviour cannot be fixed by explicitly setting ignoreExportsUsedInFile: false in the config.

In the attached repro, I have created two exported functions, and three exported types. The unused internalFunction is correctly reported, however only the ThisInterfaceDoesFail interface is reported, and not the ThisInterfaceDoesNotFail interface, despite it being an unused export.

I've identified this as the first bad commit: 14d2cfc2773e1615373dd0e69c152c3edb7d1255, released in 5.32.0.

Thanks @adamrutherfordshaw! Unfortunately it's a tad less straightforward so we've needed a few more iterations to get it right. Any chance you could give this version a shot in your project(s) before we release?

npm i -D https://pkg.pr.new/knip@80537c5

Just pulled down and tested in two projects and the repro I linked, works great ๐Ÿ‘Œ Thanks! ๐Ÿ™‚

๐Ÿš€ This issue has been resolved in v5.36.7. See Release 5.36.7 for release notes.

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

Thanks for confirming!