String Enums
👨💼 We're building an order management system. Orders go through different
statuses, and we want type-safe status values.
enum OrderStatus {
Pending = 'pending',
Processing = 'processing',
Shipped = 'shipped',
Delivered = 'delivered',
}
- Create an
OrderStatusenum with the statuses above - Create an order object that uses the enum
- Create a function that handles each status
💰 Using enum values:
const status = OrderStatus.Pending
if (status === OrderStatus.Shipped) {
// ...
}
If you see an "experimental transform-types" warning when running this step,
that's from the workshop runtime and can be ignored.