TSTypeScript · Lesson 4 of 10
Typed Functions
Adding types to functions is where TypeScript pays off most immediately — your editor knows what you're passing and what you'll get back, and the compiler catches mismatches before you run anything.
✦ Tip
Always annotate function return types explicitly on public API functions — even though TypeScript can infer them. Explicit return types act as a contract: if you accidentally return the wrong type, TypeScript flags the function body, not the caller.
Always annotate function return types explicitly on public API functions — even though TypeScript can infer them. Explicit return types act as a contract: if you accidentally return the wrong type, TypeScript flags the function body, not the caller.