A class defines a member twice

tx0/ts:duplicate-class-memberdefaultwarningbug

What it finds

class A { run() {} run() {} }: a class member defined twice under the same name replaces the first definition, which then never runs.

Static and instance members are kept apart. A getter and a setter of the same name make one property. TypeScript's overload signatures and abstract methods have no body and are not definitions, and fields count only with an initializer: without one they declare a type, or a field that starts as undefined either way. Ambient classes, declared with declare class, define nothing. Names are compared as keys: 'run' and run are the same. Computed names are not compared.

From the rule's source, duplicate_class_member.rs.

Example from the rule's tests
class Service {  start() {    return 1;  }  stop() {}  start() {tx0 reports: start is defined again    return 2;  }  get value() { return 1; }  set value(v: number) {}  static stop() {}  load(x: string): void;  load(x: number): void;  load(x: unknown) {}  field = 1;  "field" = 2; // want "`"field"` is defined again"  declared: number;  declared: number;} declare class Ambient {  run(): void;  run(): void;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:duplicate-class-member" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:duplicate-class-member] reason="..."

tx0 explain tx0/ts:duplicate-class-member shows the same in the terminal. Found a false positive? Report it.