Intersection Types

An intersection type combines multiple types into a single type.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
type User = {
name: string;
};

type Address = {
city: string;
country: string;
};

// Intersection Type "Customer"
type Customer = User & Address;

const benny: Customer = {
city: 'Berlin',
country: 'Germany',
name: 'Benny'
};