TYPESCRIPTChapter 1 · TS Basics
Function parameter and return types
In TypeScript, you must annotate function parameters and their return types. This ensures callers pass the correct arguments and receive the expected outputs.
Worked example
How it reads
- (meters: number) restricts parameter inputs to numbers only
- : string asserts that the function must return a string

Cloud tip: Functions that do not return any value should be annotated with a return type of void.


