RecipesChapter 3: The Type System

Understanding void

Recipe 3.6 from The TypeScript Cookbook

function fetchResults(
  callback: (statusCode: number, results: number[]) => void
) {
  // get results from somewhere ...
  const didItWork = callback(200, results);
  // didItWork is `undefined` in the type system,
  // even though it would be a boolean with `handler`.
}
Open in TypeScript Playground →