# @typescript-eslint/no-dupe-class-members

> Disallow two class members with the same name

If a class declares the same name twice, the last declaration wins and the first one is never used. Nothing fails at runtime, so the dead code stays and misleads anyone who reads it.

A getter and a setter with the same name are a pair and are allowed. So are a static member and an instance member with the same name. Overload signatures, which repeat the name without a body, aren't reported.

It's the TypeScript version of `no-dupe-class-members`. Unlike that rule, it skips members with a name in brackets, such as `["save"]`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-dupe-class-members" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```ts
class Store {
  save() {
    return "first";
  }

  save() {
    return "second";
  }
}
```

Not reported:

{/* good */}
```ts
class Store {
  save(id: number): void;
  save(name: string): void;
  save(key: number | string): void {}

  get size() {
    return 0;
  }

  set size(value: number) {}

  static reset() {}
  reset() {}

  clear() {}
  ["clear"]() {}
}
```

## When not to use it

TypeScript reports duplicate members on its own. If you type check your code, you don't need this rule.
