On this page
  1. void
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

void

Prev: `never` | Up: builtins | Next: `keyof`
Rel: builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — void
Tags: #public #web #typescript #builtins #tier/core


Syntax & Overview

type Callback = () => void;

Indicates a function's return value is not used.

Notes & Pitfalls

Example

function runTask(cb: () => void): void {
  cb();
}

const items: number[] = [];
runTask(() => items.push(1)); // allowed: return value is ignored

Linked from

Related notes