Ch 4 · Functions That State Their Terms · TypeScript
Topic 4 of 6 in TypeScript — Types That Protect Paid Work — 4 lessons.
Parameters and Return Types
Function boundaries are where annotations earn their keep. Inside a function, TypeScript can usually infer. At the boundary it cannot — a parameter has no assigned value to reason about, so an unannotated parameter is a hole in the fence.
Optional and Default Parameters
A question mark makes a parameter optional. An equals sign gives it a default, which also makes it optional and tells TypeScript what type it is without your saying so.
The Invoice Total
This is the shape of code you will genuinely write for a local client: a list of line items, a tax rate, a total. Interfaces describe the data, literal types keep the units honest, and function signatures make each step's contract explicit.