We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Function Types

Functions themselves are values in JavaScript (and by extension, TypeScript), which means they must also have a type, right? You might think:

Oh, easy. They're probably some "function" type.

Not so fast. Function types are much more specific than that. In TypeScript, a function's type includes information about its parameters and return value.

Defining Function Types

The syntax for a function type looks like this:

(param1: type1, param2: type2, ...) => returnType

For example, a function that takes two numbers and returns a number:

(a: number, b: number) => number;

and both of these functions are of that type:

const add = (a, b) => a + b;
const subtract = (a, b) => a - b;