> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# related-getter-setter-pairs

[Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4)
## Configuration

| Preset                         | Configured Value |
| ------------------------------ | ---------------- |
| ✅ ts.configs.strictTypeChecked | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/related-getter-setter-pairs': 'error',
    },
  },
]);
```

## Rule Details

Enforce that `get()` types are assignable to their equivalent `set()` types. A getter and setter for the same property should have compatible types. The getter's return type should be assignable to the setter's parameter type; otherwise it creates a confusing API where writing a value and then reading it back produces a different type.

Examples of **incorrect** code for this rule:

```typescript
interface Foo {
  get value(): string;
  set value(newValue: number);
}

class Bar {
  get prop(): string {
    return this._prop;
  }
  set prop(newValue: number) {
    this._prop = String(newValue);
  }
}
```

Examples of **correct** code for this rule:

```typescript
interface Foo {
  get value(): string;
  set value(newValue: string);
}

class Bar {
  get prop(): string {
    return this._prop;
  }
  set prop(newValue: string) {
    this._prop = newValue;
  }
}
```

## Original Documentation

- [typescript-eslint: related-getter-setter-pairs](https://typescript-eslint.io/rules/related-getter-setter-pairs)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/related-getter-setter-pairs.ts)
