---
title: Avoid non-null assertion in confusing locations
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Avoid non-null assertion in confusing locations
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Avoid non-null assertion in confusing locations

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `typescript-code-style/no-confusing-non-null-assertion`

**Language:** TypeScript

**Severity:** Warning

**Category:** Error Prone

## Description{% #description %}

Using a non-null assertion (`!`) next to an assign or equals check (`=` or `==` or `===`) could be confusing.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```typescript
a! == b;
a! === b;
a + b! == c;
(obj = new new OuterObj().InnerObj).Name! == c;
(a==b)! ==c;
a! = b;
(obj = new new OuterObj().InnerObj).Name! = c;
(a=b)! =c;
```

## Compliant Code Examples{% #compliant-code-examples %}

```typescript
a == b!;
a = b!;
a !== b;
a != b;
(a + b!) == c;
(a + b!) = c;
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 