Intersection (A & B)

A type that combines all the fields of several types at once.

On this page

Example

#
TypeScript
type Timestamps = { createdAt: string; updatedAt: string }
type Lesson = { title: string; minutes: number }
type StoredLesson = Lesson & Timestamps

const lesson: StoredLesson = {
  title: 'Flexbox',
  minutes: 14,
  createdAt: '2026-09-01',
  updatedAt: '2026-09-28'
}

console.log(Object.keys(lesson).length)
Result
4

Definition and usage

#

An intersection joins types with the & sign. A value of type A & B must satisfy both types at once, meaning it has every field from A and every field from B.

It’s most often used to compose object types from smaller pieces, for example User & Timestamps, or to add fields to a type from a library. It’s the equivalent of extends for type aliases.

The intersection of mutually exclusive types (e.g. string & number) gives never. The same happens with fields that share a name but have incompatible types.

Syntax

#
Syntax
type Name = TypeA & TypeB

Good practices

#
  • Intersection is convenient for composing object types, but field name conflicts can easily produce never. Check the result in your editor.
  • With interfaces, you get the same effect through extends, which reports conflicts more clearly.

Related entries

#

Spotted a mistake or missing an example? Write to us.