Want a faster signal before interviews? Take the Interview Ready Check →

DAY 7 OF 30

Intersection types

Yesterday, in one sentence

What is a type alias in TypeScript?

Interview question

Can you specify optional properties on an object type in TypeScript, and if so how?

An intersection type combines two or more types into one that has everything from all of them. You write the types separated by an &.

type Contact = { email: string };
type Named = { name: string };

type Person = Contact & Named; // intersection type

const logan: Person = {
  email: "logan@mansion.com",
  name: "Logan",
};

const scott: Person = { name: "Scott" };
// ❌ Property 'email' is missing in type '{ name: string; }'

A union typeUnion Type written with | means one type or the other. An intersection type written with & means both at once.

Intersection types are how you build a bigger shape out of smaller ones instead of repeating properties.

type Timestamps = {
  readonly createdAt: string;
  updatedAt?: string;
};

type Mutant = Named &
  Timestamps & {
    power: string;
  };

const jean: Mutant = {
  name: "Jean",
  power: "telepathy",
  createdAt: "2026-01-01",
};

Check yourself

Given type Person = { name: string } & { age: number }, which object is valid?
What is the difference between a union type and an intersection type?