Skip to content
dreamcode
dreamcode
Map
Aliases
Lesson 10 of 26
+15 XP on finish
TYPESCRIPTChapter 2 · TS Unions & Enums

Type Aliases vs Interfaces

Type Aliases (type) name any type, including primitives, unions, and tuples. Interfaces (interface) describe object structures and support declaration merging. Use interfaces for objects and type aliases for unions/primitives.

Worked example

How it reads

  • type ID defines a name for a union or generic type
  • interface Coordinate is strictly for object shapes
Cloud tip: Interfaces can be extended using the extends keyword, making them great for class descriptions.
index.ts
TYPESCRIPT
type-checked, then run in your browser
Console
Run your code to see its output here.
YOUR TURN

Add "retired" to Status, create pioneer with that status, and log pioneer.status: retired.

Press Run to check your work.