• 1 Post
  • 6 Comments
Joined 1 year ago
cake
Cake day: June 27th, 2023

help-circle




  • At work, when I was helping with some frontend stuff, we used object literals.

    const DIRECTIONS = {
      UP: "UP",
      DOWN: "DOWN"
    } as const;
    
    type DIRECTIONS = typeof DIRECTIONS[keyof typeof DIRECTIONS];
    

    Taken from option 2 in this blog post. https://maxheiber.medium.com/alternatives-to-typescript-enums-50e4c16600b1___