no-unused-private-class-members
Configuration
Rule Details
Disallow unused private class members.
This rule extends the base ESLint no-unused-private-class-members rule by recognizing members declared with TypeScript's private accessibility modifier and parameter properties (constructor(private x: T)), in addition to JavaScript's #-prefixed private fields.
A private class member is considered used when its value is read at least once. Pure writes do not count — a field that is only assigned but never read can be removed with no observable effect. Getter and setter accessors are the exception: any access keeps them alive, since they can have side effects.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule has no options.
Known Limitations
Detection is shape-based, so the rule cannot see uses that reach the member through these indirect patterns:
- Access through a variable whose type annotation is more complex than a single
Tortypeof T(unions, intersections, generic constraints). - External access via bracket notation with a dynamic key (
instance[someVar]). - Usages reached through multi-step
this-aliasing (let X = this; let Y = X; Y.foo).