> 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.

# non-nullable-type-assertion-style

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

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


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

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

## Rule Details

Enforce non-null assertions over explicit type assertions when the asserted type is the same as the original type minus `null` and `undefined`. A non-null assertion (`!`) is a more concise way to remove `null` and `undefined` from a type than using an `as` type assertion.

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

```typescript
const foo = bar as string; // when bar is string | null
const baz = bar as string; // when bar is string | undefined
const qux = bar as string; // when bar is string | null | undefined
```

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

```typescript
const foo = bar!;
const baz = bar as string | null;
const qux = bar as SomeDifferentType;
```

## Original Documentation

- [typescript-eslint: non-nullable-type-assertion-style](https://typescript-eslint.io/rules/non-nullable-type-assertion-style)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts)
