Module 01 Β· TypeScript for the Backend β Lesson 3 of 3 Β· ~11 min
Functions, async & a first generic
Typed functions
A function is a boundary β the place annotations earn their keep. You type each parameter and the return value; TypeScript checks every call site against that contract.
function priceLabel(cents: number): string {
return "$" + (cents / 100).toFixed(2);
}Read it as: takes a number, gives back a string. Call it with a string and the compiler stops you. Arrow-function form is the same contract: const priceLabel = (cents: number): string => ....