String Enums
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',
}
π¨ Open
and:
- Create a string enum
OrderStatuswith the members and values shown above - Create an
orderobject withid: string,status: OrderStatus, andcustomerName: string - Implement
getStatusMessage(status: OrderStatus): stringso each enum member returns a distinct non-empty message (exact wording is up to you) - Export
OrderStatus,order, andgetStatusMessageby name
Completion criteria
- Named exports:
OrderStatus,order,getStatusMessage OrderStatus.Pending === 'pending'(and the other members match their string values)order.statusis one of the enum values;idandcustomerNameare non-empty stringsgetStatusMessagereturns four different non-empty strings for the four statuses
If you see an "experimental transform-types" warning when running this step,
that's from the workshop runtime and can be ignored.