# bun:test/require-mock-type-parameters

> Require a type parameter on `jest.fn()` and `vi.fn()`

A plain `jest.fn()` is typed as a function that takes any arguments and returns `any`. TypeScript then accepts `mockReturnValue(42)` on a mock of a function that returns a string. With a type parameter, TypeScript checks the arguments you pass to the mock and the value it returns.

A mock with an implementation, such as `jest.fn(() => 1)`, is reported too, even though TypeScript infers its type. `mock()` isn't checked, and neither are JavaScript files.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"bun:test/require-mock-type-parameters" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```ts
import { jest, vi } from "bun:test";

const findUser = jest.fn();
const log = vi.fn((message: string) => {});
```

Not reported:

{/* good */}
```ts
import { jest, mock, vi } from "bun:test";

type User = { name: string };

const findUser = jest.fn<(id: string) => Promise<User>>();
const log = vi.fn<(message: string) => void>((message) => {});
const send = mock();
```
