Exports previously legitimately reported as unused are no longer reported
Hi, after seeing that #697 was closed, I updated knip in the repro for that issue (here) to verify.
The behavior on v5.23.0 was that a, b, c, and d were reported as unused while the other two exports that used multiline exports were not reported (even though they were also unused). The new behavior on v5.23.1 is that none of the exports are reported as unused.
There's a few things to this one. We're only talking about the combination of:
-
ignoreExportsUsedInFile: true - The
export { id }notation
Unfortunately, internally when using the TypeScript AST nodes there's a big difference between these notations:
export const id = 1;
const id = 1;
export { id };
With the latter syntax, I couldn't find a reliable way to detect whether id was used more often or not within the same module. That's why I've opted for the stability of assuming export { id } is referenced (which technically could be argued it is, but it could be only the declaration, not other usage).
So this is the situation now, until we've found a reliable way to do it better.
Additional notes:
- Usually
ignoreExportsUsedInFileis used only for types, since values don't need to be exported. E.g."ignoreExportsUsedInFile": { "interface": true, "type": true } - The former syntax doesn't have this issue, so purely from a Knip perspective that would be recommended.
Closing this issue as part of a general cleanup to keep this project sustainable and optimize my time working on it. If you think this is inappropriate or if there is no workaround and you feel stuck, feel free to open a new issue. Thanks for your understanding.