# prefer-return-this-type

Rule `typescript/prefer-return-this-type`. Enforce that `this` is used when only `this` type is returned

- Source: typescript
- Technologies: TypeScript
- Kind: style
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 46.6M weekly downloads of presets that enable it
- Trend: +31.9% last quarter
- Rank: #285 by reach, #1111 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/prefer-return-this-type` | no | safe | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/prefer-return-this-type) |
| Oxlint | `typescript/prefer-return-this-type` | no | safe | plugin `typescript`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/prefer-return-this-type.html) |

## Code examples

### Incorrect: the rule reports this

```ts
class Foo {
  f1(): Foo {
    return this;
  }
  f2 = (): Foo => {
    return this;
  };
  f3(): Foo | undefined {
    return Math.random() > 0.5 ? this : undefined;
  }
}
```

### Correct: the rule accepts this

```ts
class Foo {
  f1(): this {
    return this;
  }
  f2() {
    return this;
  }
  f3 = (): this => {
    return this;
  };
  f4 = () => {
    return this;
  };
}

class Base {}
class Derived extends Base {
  f(): Base {
    return this;
  }
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/prefer-return-this-type": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/prefer-return-this-type": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [typescript-eslint strict type-checked](https://lintradar.dev/presets/typescript-eslint-strict-type-checked.md) | ESLint | `@typescript-eslint/eslint-plugin` | 75 | 175.9M | +29.5% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [typescript/no-unsafe-enum-assignment](https://lintradar.dev/rules/typescript/no-unsafe-enum-assignment.md): Disallow assigning non-enum values to enum typed locations
- [typescript/related-getter-setter-pairs](https://lintradar.dev/rules/typescript/related-getter-setter-pairs.md): Enforce that `get()` types should be assignable to their equivalent `set()` type
- [typescript/no-confusing-non-null-assertion](https://lintradar.dev/rules/typescript/no-confusing-non-null-assertion.md): Disallow non-null assertion in locations that may be confusing
- [typescript/use-unknown-in-catch-callback-variable](https://lintradar.dev/rules/typescript/use-unknown-in-catch-callback-variable.md): Enforce typing arguments in Promise rejection callbacks as `unknown`
- [typescript/consistent-generic-constructors](https://lintradar.dev/rules/typescript/consistent-generic-constructors.md): Enforce specifying generic type arguments on type annotation or constructor name of a constructor call
- [typescript/ban-tslint-comment](https://lintradar.dev/rules/typescript/ban-tslint-comment.md): Disallow `// tslint:<rule-flag>` comments

---

Web page: https://lintradar.dev/rules/typescript/prefer-return-this-type. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
