Type aliases
📚 What are Type Aliases in TypeScript? A type alias gives a NAME to any type so you can reuse it. Instead of writing { name: string; age: number } everywhere, you write type User = { name: string; age: number } once and use User wherever you need it. Aliases work for objects, unions, functions, tu…

Appy Says…
Interfaces define object shapes. But what about union types, tuples, function types, primitives with extra meaning? Type aliases let you name any type — not just objects — and use it everywhere.
What are Type Aliases?
A type alias creates a new name for any type — primitives, unions, intersections, tuples, function types, or objects.
- •Syntax:
type Name = TypeExpression; - •
type UserId = string;— alias for a primitive - •
type Status = 'idle' | 'loading' | 'error';— alias for a union - •
type Point = [number, number];— alias for a tuple - •
type Handler = (event: Event) => void;— alias for a function type - •
type User = { id: UserId; name: string; };— alias for an object - •Intersection:
type AdminUser = User & { permissions: string[] };
Think of it like naming a Minecraft item set
Instead of writing out 'diamond_sword, diamond_pickaxe, diamond_axe' every time, you name it 'DiamondTools'. Type aliases do the same: name a complex type expression once, use the name everywhere — readable, reusable, single source of truth.
How It Works
- •1.
type Status = 'idle' | 'loading' | 'success' | 'error'; - •2. Use anywhere:
const status: Status = 'loading'; - •3. Function return:
function getStatus(): Status { ... } - •4. Intersection:
type WithTimestamps = { createdAt: Date; updatedAt: Date; }; - •5.
type UserWithTimestamps = User & WithTimestamps; - •6. Generic alias:
type Nullable<T> = T | null;
Real-World Examples
- •
type ApiResponse<T> = { data: T; status: number; message: string; }; - •
type Coords = { lat: number; lng: number; }; - •
type EventHandler = React.MouseEventHandler<HTMLButtonElement>; - •
type Maybe<T> = T | null | undefined;
Key Facts
- •Type aliases and interfaces are mostly interchangeable for objects — the community convention: use
typefor unions/tuples/complex types; useinterfacefor object shapes you might extend - •Type aliases CANNOT be re-opened (unlike interfaces); you can't add properties later with declaration merging
- •Utility types like
Partial<T>,Required<T>,Pick<T, K>are all type aliases - •The TypeScript standard library is full of type aliases:
Record<K, V>,Readonly<T>, etc.
Watch Out!
Don't create type aliases for single-use types — they add indirection without value. Create an alias when: (a) the type is used in 2+ places, (b) giving it a name makes it more readable, or (c) it's a complex expression that would be hard to read inline.
Remember
type X = ... names any type. Use for unions, tuples, function types, intersections. For object shapes you'll extend, prefer interface. Both work for objects — pick one and be consistent.
What You Learned
- •Type aliases name any TypeScript type: unions, tuples, functions, objects, intersections
- •Use type for complex expressions; interface for extensible object shapes (convention)
- •Unlocks: readable, reusable type definitions; building your own type vocabulary for an app
Key Facts
- →Type aliases and interfaces are mostly interchangeable for objects — the community convention: use
typefor unions/tuples/complex types; useinterfacefor object shapes you might extend - →Type aliases CANNOT be re-opened (unlike interfaces); you can't add properties later with declaration merging
- →Utility types like
Partial<T>,Required<T>,Pick<T, K>are all type aliases - →The TypeScript standard library is full of type aliases:
Record<K, V>,Readonly<T>, etc.
Real-World Examples
Remember
type X = ... names any type. Use for unions, tuples, function types, intersections. For object shapes you'll extend, prefer interface. Both work for objects — pick one and be consistent.
Quick Quiz
type Alias = ... is?