

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Intersections of Types
incomplete
2: The Never Type
incomplete
3: Intersecting Incompatible Types
incomplete
4: Intersections vs. Unions
incomplete
5: Super Set Unions
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
So we've covered how unions (|) and intersections (&) are both used to smoosh types together... but which should you use?
| operator (suspiciously similar to the logical OR operator)& operator (like logical AND)type Human = {
name: string;
age: number;
};
type Elf = {
name: string;
ears: "pointy";
};
// Must have name, age, and pointy ears
type ElfHuman = Human & Elf;
// Must have name (shared between Human and Elf)
// Can have either age or ears (or both)
type ElfOrHuman = Human | Elf;
Support.ai stores information about different types of users who interact with support tickets. However, there's a problem, our SupportAgentUser type is impossible to use (incompatible never).