knip icon indicating copy to clipboard operation
knip copied to clipboard

Unused export inside exported namespace not reported

Open sidu4u opened this issue 1 year ago • 5 comments

I have created a workspace to replicate this issue:

I have a namespace Parent with 2 exports Child1 and Child2. While Child1 is used in App.tsx. Child2 is unsed. Knip is not reporting Child2 as unused.

I have added issue types nsExports and nsTypes while running knip. Still not getting the unused Export

sidu4u avatar Jun 27 '24 03:06 sidu4u

Unfortunately namespaces are not supported yet. Just looked into it and did some preliminary work, but it's not trivial.

webpro avatar Jun 27 '24 10:06 webpro

@webpro if namespaces are not supported why is there an issue type nsExport with description Namespace with export is referenced, but not export itself

sidu4u avatar Jun 28 '24 10:06 sidu4u

Good question, I need to document this better.

There's two different types of namespaces here:

  1. The import * as NS from '..' where NS is the namespace, which is what nsExports and https://knip.dev/guides/namespace-imports is about.
  2. The namespace feature of TypeScript (https://www.typescriptlang.org/docs/handbook/namespaces.html) which is not supported yet by Knip.

webpro avatar Jun 28 '24 10:06 webpro

Is it ok if I open a PR for this, we are loving knip at work and will like to contribute.

sidu4u avatar Jun 28 '24 11:06 sidu4u

Absolutely! Let me know if you need any assistance.

webpro avatar Jun 29 '24 08:06 webpro

Closing this due to inactivity (also namespaces are going out of fashion).

webpro avatar Feb 11 '25 06:02 webpro