Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting unused accessors (getters & setters) #297

Closed
domsleee opened this issue Oct 15, 2023 · 2 comments
Closed

Detecting unused accessors (getters & setters) #297

domsleee opened this issue Oct 15, 2023 · 2 comments
Labels
feature request Feature request

Comments

@domsleee
Copy link

domsleee commented Oct 15, 2023

Hey, thanks for this great program 馃槃

On version 2.33.3, I have found that it doesn't seem to detect unused getters and setters of a class

export class MyClass {
  public usedMethod() {
    console.log("I am used");
  }

  public unusedMethod(): string {
    return "unusedMethod";
  }

  public get unusedGetter(): string {
    return "unusedGetter";
  }

  public set unusedSetter(_value: string) {
    console.log('unusedSetter');
  }
}
const c = new MyClass();
c.usedMethod();

It outputs this:

Unused exported class members (1)
unusedMethod  MyClass  src/class.ts

I would have expected unusedSetter and unusedGetter to appear in the list.

Is this something knip could support?

P.S. It looks like #274 is about unused methods of objects, this one is specifically about getters/setters of classes. They are similar features 馃憤

@domsleee domsleee added the feature request Feature request label Oct 15, 2023
@webpro
Copy link
Collaborator

webpro commented Oct 16, 2023

This sounds like a missing feature, I'll look into it.

@webpro
Copy link
Collaborator

webpro commented Oct 17, 2023

馃殌 This issue has been resolved in v2.34.0. See Release 2.34.0 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants