> 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-asserted-optional-chain

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

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ 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-asserted-optional-chain': 'error',
    },
  },
]);
```

## Rule Details

Disallow non-null assertions after an optional chain expression.

Optional chain expressions (`?.`) are designed to return `undefined` if the value is nullish. Using a non-null assertion (`!`) after an optional chain expression is unsafe, as it defeats the purpose of the optional chain.

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

```typescript
foo?.bar!;
foo?.bar()!;
```

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

```typescript
foo?.bar;
foo?.bar();
```

## Original Documentation

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