A function's promise
A typed function is a contract: "give me these, I'll give you that." TypeScript checks both sides — every caller and the function's own return statements.
Parameters, returns and options
function bill(amount: number, tip = 10, note?: string): string {
const total = amount + (amount * tip) / 100;
return note ? `${total} (${note})` : String(total);
}
bill(1000);
bill(1000, 15, "birthday");
bill();
function log(message: string): void {
console.log(message);
}