# no-unsafe-assignment

Rule `typescript/no-unsafe-assignment`. Disallow assigning a value with type `any` to variables and properties

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: yes
- Autofix: no
- Reach: 46.6M weekly downloads of presets that enable it
- Trend: +31.9% last quarter
- Rank: #275 by reach, #1101 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```ts
const x = 1 as any,
  y = 1 as any;
const [x] = 1 as any;
const [x] = [] as any[];
const [x] = [1 as any];
[x] = [1] as [any];

function foo(a = 1 as any) {}
class Foo {
  constructor(private a = 1 as any) {}
}
class Foo {
  private a = 1 as any;
}

// generic position examples
const x: Set<string> = new Set<any>();
const x: Map<string, string> = new Map<string, any>();
const x: Set<string[]> = new Set<any[]>();
const x: Set<Set<Set<string>>> = new Set<Set<Set<any>>>();
```

### Correct: the rule accepts this

```ts
const x = 1,
  y = 1;
const [x] = [1];
[x] = [1] as [number];

function foo(a = 1) {}
class Foo {
  constructor(private a = 1) {}
}
class Foo {
  private a = 1;
}

// generic position examples
const x: Set<string> = new Set<string>();
const x: Map<string, string> = new Map<string, string>();
const x: Set<string[]> = new Set<string[]>();
const x: Set<Set<Set<string>>> = new Set<Set<Set<string>>>();
```

```ts
const x: unknown = y as any;
const x: unknown[] = y as any[];
const x: Set<unknown> = y as Set<any>;
```

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/no-unsafe-assignment": "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% |
| [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/restrict-plus-operands](https://lintradar.dev/rules/typescript/restrict-plus-operands.md): Require both operands of addition to be the same type and be `bigint`, `number`, or `string`
- [typescript/no-unsafe-enum-comparison](https://lintradar.dev/rules/typescript/no-unsafe-enum-comparison.md): Disallow comparing an enum value with a non-enum value
- [typescript/prefer-reduce-type-parameter](https://lintradar.dev/rules/typescript/prefer-reduce-type-parameter.md): Enforce using type parameter when calling `Array#reduce` instead of using a type assertion
- [typescript/no-unsafe-member-access](https://lintradar.dev/rules/typescript/no-unsafe-member-access.md): Disallow member access on a value with type `any`
- [typescript/prefer-promise-reject-errors](https://lintradar.dev/rules/typescript/prefer-promise-reject-errors.md): Require using Error objects as Promise rejection reasons
- [typescript/consistent-indexed-object-style](https://lintradar.dev/rules/typescript/consistent-indexed-object-style.md): Require or disallow the `Record` type

---

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