Typed function
Functions with specified parameter and return types.
Syntax
function name(p: type): returnType { }Description
You assign types to every parameter and return value. The compiler warns you if you provide the wrong type.
Example
Loading editor…
Expected output
25
When to use?
Safe, self-documenting functions.
Common mistakes
- ⚠️ square("5") → ERROR: argument must be a number.