0Pricing
TypeScript Academy · Lesson

void, never, and Function Signatures

Understand void for no-return and never for unreachable code.

Welcome

Two special return types — void and never — represent functions that don't produce a useful value and functions that never complete normally.

void: No Meaningful Return

void is used when a function performs a side effect but doesn't return a value. It allows returning undefined but signals that the return value should not be used.
function logError(msg: string): void {
  console.error(msg);
  // implicit return undefined
}

All lessons in this course

  1. Parameter and Return Type Annotations
  2. Optional and Default Parameters
  3. Rest Parameters and Spread with Types
  4. void, never, and Function Signatures
← Back to TypeScript Academy