Overloads let a function have several distinct signatures for different argument combinations, all implemented by a single function body.
ts
function parseAmount(value: string): number;
function parseAmount(value: number): number;
function parseAmount(value: string | number): number {
return typeof value === "string" ? parseFloat(value) : value;
}
parseAmount("1.5"); // matches first signature
parseAmount(2); // matches second signatureOnly the overload signatures are visible to callers — the implementation signature (with the union) is not callable directly from outside. Overloads are most useful when the relationship between argument and return types can't be expressed with a single union signature, e.g. return type depends on which argument type was passed.