Type alias memberi nama pada tipe dengan keyword type:
type ID = string | number;
type Point = { x: number; y: number };
let userId: ID = "abc123";
let pos: Point = { x: 10, y: 20 };
Union types — bisa salah satu dari beberapa tipe:
type Status = "active" | "inactive" | "pending";
let status: Status = "active";
Intersection types — gabungan semua tipe:
type HasName = { nama: string };
type HasAge = { umur: number };
type Person = HasName & HasAge;
// Person harus punya nama DAN umur
Type vs Interface:
type— bisa untuk union, intersection, primitifinterface— bisa di-extend dan declaration merging- Untuk object shapes, keduanya bisa dipakai