Explain the concept of Union and Intersection types

Answer

// Union
let id: string | number;
id = "abc"; // Valid
id = 123;   // Valid

// Intersection
interface User {
  name: string;
}

interface Admin {
  admin: boolean;
}

type AdminUser = User & Admin;

const admin: AdminUser = { name: "John", admin: true };

Read more about TypeScript union and intersection types