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
index.ts
and:
  1. Create a string enum OrderStatus with the members and values shown above
  2. Create an order object with id: string, status: OrderStatus, and customerName: string
  3. Implement getStatusMessage(status: OrderStatus): string so each enum member returns a distinct non-empty message (exact wording is up to you)
  4. Export OrderStatus, order, and getStatusMessage by name

Completion criteria

  • Named exports: OrderStatus, order, getStatusMessage
  • OrderStatus.Pending === 'pending' (and the other members match their string values)
  • order.status is one of the enum values; id and customerName are non-empty strings
  • getStatusMessage returns 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.

Please set the playground first

Loading "String Enums"
Loading "String Enums"
Login to get access to the exclusive discord channel.
Loading Discord Posts