Function types
A function type describes which parameters a function takes and what type it returns, written as (param: Type) => Return.
A function type reads like an arrow function without a body: the parameters go in parentheses and, after =>, comes the type it returns.
type Formatter = (cents: number) => string; says: "a Formatter is any function that takes a number and returns a string".
The => here does not create a function. It only describes a shape. The parameter names are documentation; they don't have to match the names in the real function.
The type checker verifies that every function you assign to that type accepts those parameters and returns that type. This lets you pass functions as callbacks safely. When Node runs the code, this type is already gone.
In the course, export type Formatter = (cents: Cents) => string; names the shape of the function so you can reuse it.
Reach for it when: you accept a function as a parameter (a callback) or store functions in a variable or object and want to fix their shape.
Examples
Common mistake
type Formatter = (cents: number) => string; const bad: Formatter = (cents) => cents * 2; console.log(bad(5));
Why: The function returns a number, but Formatter promises a string.
How to write it: Return a string, for example String(cents * 2).
