knip
knip copied to clipboard
False positive on method that is used in base class of base class
👋 Reporting https://github.com/JoshuaKGoldberg/ts-api-utils/issues/343 over here. The relevant classes in https://github.com/JoshuaKGoldberg/ts-api-utils/blob/8c747294f24d0adca8817f4028832b855d907b5b/src/usage/scopes.ts are:
-
abstract class AbstractScope implements Scope -
class NonRootScope extends AbstractScope -
class NamespaceScope extends NonRootScope
NamespaceScope defines a finish() method. That method is referenced in the AbstractScope class method end, in a this.namespaceScopes.forEach((value) => value.finish(cb));. Yet Knip is reporting it as unused:
$ pnpm lint:knip:production
> [email protected] lint:knip:production /Users/josh/repos/ts-api-utils
> knip --config knip.production.jsonc --production
Analyzing workspace ....
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting
Unused exported class members (1)
finish NamespaceScope src/usage/scopes.ts:358:2
ELIFECYCLE Command failed with exit code 1.
Very odd. In --production mode vitest is not imported (no test files included), and that's somehow what makes the difference in behavior.
You can drop import "vitest" in src/index.ts and it won't report finish as unused anymore.