# no-unnecessary-type-assertion

Rule `typescript/no-unnecessary-type-assertion`. Disallow type assertions that do not change the type of an expression

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 75.1M weekly downloads of presets that enable it
- Trend: +52.9% last quarter
- Rank: #231 by reach, #751 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-unnecessary-type-assertion` | no | safe | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-unnecessary-type-assertion) |
| Oxlint | `typescript/no-unnecessary-type-assertion` | no | safe | plugin `typescript`, category suspicious | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-unnecessary-type-assertion.html) |
| Biome | `nursery/noUselessTypeAssertion` | yes | unsafe | group nursery, since 2.6.5 | [docs](https://biomejs.dev/linter/rules/no-useless-type-assertion/) |

## Code examples

### Incorrect: the rule reports this

```ts
const foo = 3;
const bar = foo!;
```

```ts
const foo = <number>(3 + 5);
```

```ts
type Foo = number;
const foo = <Foo>(3 + 5);
```

### Correct: the rule accepts this

```ts
const foo = <number>3;
```

```ts
const foo = 3 as number;
```

```ts
let foo = 'foo' as const;
```

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/no-unnecessary-type-assertion": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/no-unnecessary-type-assertion": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noUselessTypeAssertion": "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% |
| [typescript-eslint recommended type-checked](https://lintradar.dev/presets/typescript-eslint-recommended-type-checked.md) | ESLint | `@typescript-eslint/eslint-plugin` | 47 | 175.9M | +29.5% |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [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

- [jsdoc/no-unnecessary-type-assertion](https://lintradar.dev/rules/jsdoc/no-unnecessary-type-assertion.md): Reports redundant @type tags that match or broaden the naturally inferred TypeScript type.
- [typescript/no-misused-promises](https://lintradar.dev/rules/typescript/no-misused-promises.md): Disallow Promises in places not designed to handle them
- [typescript/no-non-null-assertion](https://lintradar.dev/rules/typescript/no-non-null-assertion.md): Disallow non-null assertions using the `!` postfix operator
- [typescript/prefer-function-type](https://lintradar.dev/rules/typescript/prefer-function-type.md): Enforce using function types instead of interfaces with call signatures
- [typescript/adjacent-overload-signatures](https://lintradar.dev/rules/typescript/adjacent-overload-signatures.md): Require that function overload signatures be consecutive
- [typescript/no-invalid-void-type](https://lintradar.dev/rules/typescript/no-invalid-void-type.md): Disallow `void` type outside of generic or return types

---

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