Type Aliases
A type alias is a nickname for any type.
Objects, unions, primitives, tuples, or functions.
Interfaces focus on object shapes.
Aliases can name almost anything.
Naming object shapes
Use type Name = { ... }.
For simple object types, aliases and interfaces feel about the same.
Pick the one that reads clearer to you.
Aliasing unions and primitives
This is where aliases shine.
A union means apple OR orange in one box.
Interfaces cannot name a union of string choices.
Type aliases can.
Combining types
Intersection types use &.
Intersection means both shapes at once.
Like filling two forms at the same time.
Unions use | and mean one of several options.
Function type aliases
You can name a whole function shape.
That keeps callback types short and clear.
A callback is a function you hand to another function.
Aliases vs interfaces
Use interface when you want merging across files.
Or a clear class implement checklist.
Use type when you need unions, intersections, or tuples.
Both are fine. Pick the clearer one.
Type aliases name hard ideas so the rest of your code stays short.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.