Function types make a program's inputs and outputs explicit. TypeScript can infer many return types, but annotations are useful at public boundaries.
Parameters
TypeScript
function formatPrice(price: number, currency = "GBP"): string { return `${currency} ${price.toFixed(2)}`; }
Return types
An optional parameter follows required parameters. A function that does not return a useful value has return type void. Do not annotate everything automatically; use annotations where they communicate an important contract.
Did you know my courses are all printer-friendly? This means you can easily export them to PDF or print them for later use.
