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

# prefer-expect-type-of

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

| Preset                     | Configured Value |
| -------------------------- | ---------------- |
| ✅ rstestPlugin.configs.all | `"warn"`         |


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

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/prefer-expect-type-of': 'error',
    },
  },
]);
```

## Rule Details

Prefers `toBeTypeOf` over comparing `typeof` with a string. The dedicated matcher makes the assertion's intent clearer and gives a better failure message.

The rule supports regular and soft Rstest assertions.

## Incorrect

```ts
expect(typeof value).toBe('string');
```

## Correct

```ts
expect(value).toBeTypeOf('string');
```

## Autofix

Rewrites the assertion to `toBeTypeOf`, leaving the `expect` factory, a message argument, and the modifier chain untouched.
