# consistent-type-assertions

Rule `typescript/consistent-type-assertions`. Enforce consistent usage of type assertions

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```ts
const x = { foo: 1 } as T;

function bar() {
  return { foo: 1 } as T;
}
```

```ts
const x = { foo: 1 } as T;

function bar() {
  return { foo: 1 } as T;
}
```

```ts
const x = ['foo'] as T;

function bar() {
  return ['foo'] as T;
}
```

### Correct: the rule accepts this

```ts
const x: T = { foo: 1 };
const y = { foo: 1 } as any;
const z = { foo: 1 } as unknown;

function bar(): T {
  return { foo: 1 };
}
```

```tsx
const x: T = { foo: 1 };
const y = { foo: 1 } as any;
const z = { foo: 1 } as unknown;
bar({ foo: 1 } as T);
new Clazz({ foo: 1 } as T);
function bar() {
  throw { foo: 1 } as Foo;
}
const foo = <Foo props={{ bar: 1 } as Bar} />;
```

```ts
const x: T = ['foo'];
const y = ['foo'] as any;
const z = ['foo'] as unknown;

function bar(): T {
  return ['foo'];
}
```

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/consistent-type-assertions": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/consistent-type-assertions": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [typescript-eslint stylistic](https://lintradar.dev/presets/typescript-eslint-stylistic.md) | ESLint | `@typescript-eslint/eslint-plugin` | 17 | 175.9M | +29.5% |
| [Create React App](https://lintradar.dev/presets/react-app.md) | ESLint | `eslint-config-react-app` | 109 | 4.1M | +4.3% |
| [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% |
| [Alloy](https://lintradar.dev/presets/alloy.md) | ESLint | `eslint-config-alloy` | 166 | 31.4K | +32.4% |

## Related rules

- [typescript/no-useless-constructor](https://lintradar.dev/rules/typescript/no-useless-constructor.md): Disallow unnecessary constructors
- [typescript/require-array-sort-compare](https://lintradar.dev/rules/typescript/require-array-sort-compare.md): Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`
- [typescript/no-unnecessary-parameter-property-assignment](https://lintradar.dev/rules/typescript/no-unnecessary-parameter-property-assignment.md): Disallow unnecessary assignment of constructor property parameter
- [typescript/no-non-null-asserted-nullish-coalescing](https://lintradar.dev/rules/typescript/no-non-null-asserted-nullish-coalescing.md): Disallow non-null assertions in the left operand of a nullish coalescing operator
- [typescript/return-await](https://lintradar.dev/rules/typescript/return-await.md): Enforce consistent awaiting of returned promises
- [typescript/unified-signatures](https://lintradar.dev/rules/typescript/unified-signatures.md): Disallow two overloads that could be unified into one with a union or an optional/rest parameter

---

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