Skip to content

Add option to ignore class member implementations #1174

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Desuuuu
Copy link

@Desuuuu Desuuuu commented Jul 12, 2025

Motivation

At the moment, abstract class members that have an implementation are never detected as unused because the implementation itself is returned in the references for the abstract class member.

export abstract class AbstractClass {
  public abstract used(): void;
  public abstract unused(): void;
}

export class ExtendedClass extends AbstractClass {
  public used(): void { }
  public unused(): void { }
}
import { AbstractClass, ExtendedClass } from './definitions';

const instance: AbstractClass = new ExtendedClass();

instance.used();

In this example, neither unused method would be detected as unused.

Changes

This PR adds the ignoreClassMemberImplementations option as well as the --ignore-class-member-implementations CLI flag.

When enabled, implementations are ignored when looking for references of class members, allowing for the removal of unused class members which are never directly referenced.

In the previous example, only AbstractClass.unused would be detected as unused at first. If it is removed, then ExtendedClass.unused would be detected as unused.

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

Successfully merging this pull request may close these issues.

1 participant