# no-incompatible-assertion-types

Rule `sonarjs/no-incompatible-assertion-types`. Assertions comparing incompatible types should not be made

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: yes
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1287 by reach, #588 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-incompatible-assertion-types` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5845/) |

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-incompatible-assertion-types": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-in-misuse](https://lintradar.dev/rules/sonarjs/no-in-misuse.md): "in" should not be used on arrays
- [sonarjs/no-incomplete-assertions](https://lintradar.dev/rules/sonarjs/no-incomplete-assertions.md): Assertions should be complete
- [sonarjs/no-implicit-global](https://lintradar.dev/rules/sonarjs/no-implicit-global.md): Variables should be declared explicitly
- [sonarjs/no-internal-api-use](https://lintradar.dev/rules/sonarjs/no-internal-api-use.md): Users should not use internal APIs
- [sonarjs/no-ignored-return](https://lintradar.dev/rules/sonarjs/no-ignored-return.md): Return values from functions without side effects should not be ignored
- [sonarjs/no-interpolation-in-inline-snapshots](https://lintradar.dev/rules/sonarjs/no-interpolation-in-inline-snapshots.md): Inline snapshots should not contain interpolations

---

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