> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-non-null-assertion

[Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1)
## Configuration

| Preset                         | Configured Value |
| ------------------------------ | ---------------- |
| ✅ ts.configs.strict            | `"error"`        |
| ✅ ts.configs.strictTypeChecked | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-non-null-assertion': 'error',
    },
  },
]);
```

## Rule Details

Disallows non-null assertions using the `!` postfix operator.

TypeScript's `!` non-null assertion operator asserts to the type system that an expression is non-nullable. Using assertions to tell the type system new information is often a sign that code is not fully type-safe. It's generally better to structure program logic so that TypeScript understands when values may be nullable.

Examples of **incorrect** code for this rule:

```typescript
interface Example {
  property?: string;
}
declare const example: Example;
const includesBaz = example.property!.includes('baz');
```

Examples of **correct** code for this rule:

```typescript
interface Example {
  property?: string;
}
declare const example: Example;
const includesBaz = example.property?.includes('baz') ?? false;
```

## Original Documentation

- [typescript-eslint: no-non-null-assertion](https://typescript-eslint.io/rules/no-non-null-assertion)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/no-non-null-assertion.ts)
