Modeling Data with Union and Intersection Types
type Doll = ToyBase & {
material: "plush" | "plastic";
};
function checkDoll(doll: Doll) {
if (doll.material === "plush") {
// do something with plush
} else {
// doll.material is "plastic", there are no other options
}
}