Enum vs Union Types

Enum Vs Union
πŸ‘¨β€πŸ’Ό You've already created enums. Now let's migrate them to union types which is the preferred approach in modern TypeScript.
The code already has an enum-based logging function. Your task is to create a union-based version.
🐨 Open
index.ts
and:
  1. Create a new function logWithUnion that uses an inline union type instead of the LogLevel enum
  2. The union type should be: 'debug' | 'info' | 'warn' | 'error'
  3. Export both functions so we can compare them
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 "Enum vs Union Types"
Loading "Enum vs Union Types"
Login to get access to the exclusive discord channel.
Loading Discord Posts