# strict-void-return

Rule `typescript/strict-void-return`. Disallow passing a value-returning function in a position accepting a void function

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 2.6M weekly downloads of presets that enable it
- Trend: +92.2% last quarter
- Rank: #1478 by reach, #288 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/strict-void-return` | no | suggestion | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/strict-void-return) |
| Oxlint | `typescript/strict-void-return` | no | no | plugin `typescript`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/typescript/strict-void-return.html) |

## Code examples

### Incorrect: the rule reports this

```ts
const getNothing: () => void = () => 2137;
const getString: () => string = () => 'Hello';
const maybeString = Math.random() > 0.1 ? getNothing() : getString();
if (maybeString) console.log(maybeString.toUpperCase()); // ❌ Crash if getNothing was called
```

```ts
declare function takesCallback(cb: () => void): void;

takesCallback(async () => {
  const response = await fetch('https://api.example.com/');
  const data = await response.json();
  console.log(data);
});
```

```ts
declare function takesCallback(cb: () => void): void;

takesCallback(function* () {
  console.log('Hello');
  yield;
  console.log('World');
});
```

### Correct: the rule accepts this

```ts
const getNothing: () => void = () => {};
const getString: () => string = () => 'Hello';
const maybeString = Math.random() > 0.1 ? getNothing() : getString();
if (maybeString) console.log(maybeString.toUpperCase()); // ✅ No crash
```

```ts
declare function takesCallback(cb: () => void): void;

takesCallback(() => {
  (async () => {
    const response = await fetch('https://api.example.com/');
    const data = await response.json();
    console.log(data);
  })().catch(console.error);
});
```

```ts
declare function takesCallback(cb: () => void): void;

takesCallback(() => {
  function* gen() {
    console.log('Hello');
    yield;
    console.log('World');
  }
  for (const _ of gen());
});
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/strict-void-return": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "typescript/strict-void-return": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [typescript/promise-function-async](https://lintradar.dev/rules/typescript/promise-function-async.md): Require any function or method that returns a Promise to be marked async
- [typescript/non-nullable-type-assertion-style](https://lintradar.dev/rules/typescript/non-nullable-type-assertion-style.md): Enforce non-null assertions over explicit type assertions
- [typescript/strict-boolean-expressions](https://lintradar.dev/rules/typescript/strict-boolean-expressions.md): Disallow certain types in boolean expressions
- [typescript/no-restricted-types](https://lintradar.dev/rules/typescript/no-restricted-types.md): Disallow certain types
- [typescript/prefer-nullish-coalescing](https://lintradar.dev/rules/typescript/prefer-nullish-coalescing.md): Enforce using the nullish coalescing operator instead of logical assignments or chaining
- [typescript/prefer-includes](https://lintradar.dev/rules/typescript/prefer-includes.md): Enforce `includes` method over `indexOf` method

---

Web page: https://lintradar.dev/rules/typescript/strict-void-return. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
