# prefer-ts-expect-error

Rule `typescript/prefer-ts-expect-error`. Enforce using `@ts-expect-error` over `@ts-ignore`

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: no
- Autofix: yes, in at least one linter
- Deprecated: yes
- Reach: 2.1M weekly downloads of presets that enable it
- Trend: +151.7% last quarter
- Rank: #1516 by reach, #20 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```ts
// @ts-ignore
const str: string = 1;

/**
 * Explaining comment
 *
 * @ts-ignore */
const multiLine: number = 'value';

/** @ts-ignore */
const block: string = 1;

const isOptionEnabled = (key: string): boolean => {
  // @ts-ignore: if key isn't in globalOptions it'll be undefined which is false
  return !!globalOptions[key];
};
```

### Correct: the rule accepts this

```ts
// @ts-expect-error
const str: string = 1;

/**
 * Explaining comment
 *
 * @ts-expect-error */
const multiLine: number = 'value';

/** @ts-expect-error */
const block: string = 1;

const isOptionEnabled = (key: string): boolean => {
  // @ts-expect-error: if key isn't in globalOptions it'll be undefined which is false
  return !!globalOptions[key];
};
```

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-ts-expect-error": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/prefer-ts-expect-error": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [typescript/consistent-return](https://lintradar.dev/rules/typescript/consistent-return.md): Require `return` statements to either always or never specify values
- [typescript/prefer-enum-initializers](https://lintradar.dev/rules/typescript/prefer-enum-initializers.md): Require each enum member value to be explicitly initialized
- [typescript/parameter-properties](https://lintradar.dev/rules/typescript/parameter-properties.md): Require or disallow parameter properties in class constructors
- [typescript/explicit-member-accessibility](https://lintradar.dev/rules/typescript/explicit-member-accessibility.md): Require explicit accessibility modifiers on class properties and methods
- [typescript/no-unsafe-type-assertion](https://lintradar.dev/rules/typescript/no-unsafe-type-assertion.md): Disallow type assertions that narrow a type
- [typescript/prefer-regexp-exec](https://lintradar.dev/rules/typescript/prefer-regexp-exec.md): Enforce `RegExp#exec` over `String#match` if no global flag is provided

---

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