TypeScript
TypeScript FunctionsTypeScript Functions
TypeScript strictly types function inputs and outputs.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
Functions are the core building blocks of JavaScript. TypeScript allows developers to lock down exactly what type of data goes into a function as arguments, and exactly what type of data the function is allowed to return.
Syntax
Syntax
Key Points
- Define argument types inside the parentheses `(a: number)`.
- Define the return type after the parentheses `(): number`.
- Use `void` if the function does not return anything.
- TypeScript throws an error if you pass the wrong number of arguments.