void type

Represents the absence of a meaningful return value from a function.

Since TS 1.0 Spec ↗

Syntax

void

Examples

function log(msg: string): void {
  console.log(msg);
}
type Cb = () => void;
const cb: Cb = () => 42; // allowed; return value ignored

Notes

`void` is the inferred return type of functions that do not return a value. A `() => void` type permits implementations that return something, but the value is treated as ignorable by callers. Distinct from `undefined`, which is a concrete value type.

See also