# Function Types — TypeScript

Source: https://www.geekswithgeeks.com/en/typescript/ts-function-types

> Describe the shape of a function as a type, useful for callbacks.

## A type for functions

A function type looks like an arrow function signature: params in, type out.

```typescript
type MathOp = (a: number, b: number) => number;

const add: MathOp = (a, b) => a + b;
const multiply: MathOp = (a, b) => a * b;
```

## Typing callbacks

Function-type parameters let TS check the callback you pass in — the wrong shape is flagged immediately.

## void vs undefined

`void` means "the return value should be ignored"; `undefined` means "the value is literally `undefined`". Use `void` for callback return types.
