Để tạo kiểu union từ bí danh kiểu (type alias) hoặc thuộc tính interface:
// a simple interface
interface Car {
name: string;
yearMade: number;
}
// make a union type from the `name` and
// `yearMade` properties from the `Car` interface
type NameOrYear = Car["name" | "yearMade"]; // NameOrYear -> string | number