Understanding TypeScript Intersection Types

Start with two event types that share properties.

Without an intersection, both types repeat those properties.

type Conference = {
 title: string,
 description: string,
 location: string,
 talks: string[]
}
type Webinar = {
 title: string,
 description: string,
 invitationLink: string,
 talks: string[]
}

But you can define a base type and use intersection types to define new types.

type TalkBase = {
 title: string,
 description: string,
}
type Conference = TalkBase & {
 location: string,
 talks: string[]
}
type Webinar = TalkBase & {
 invitationLink: string,
 talks: string[]
}