Functions are the heart of TypeScript programs. You can describe a function's shape with a call signature:
type MathOperation = (a: number, b: number) => number;
const add: MathOperation = (a, b) => a + b;Function overloads let one function name support different input shapes with different return types:
function parse(input: string): string[];
function parse(input: number): number[];
function parse(input: string | number) {
// Implementation handles both cases
}You write multiple signatures (overloads), then one implementation that handles all cases. The compiler picks the right signature based on what you pass in.
In this category, you'll:
type Fn = (x: number) => string)name?: string) and rest parameters (...args: number[])Best practice: Keep each branch simple and predictable. The focus is on readable types with small, safe implementations.