I am looking for a string enum that can be iterated.
What I tried so far:
String union types:
type t = "p1" | "p2" | "p3"
Problem: Can't be iterated
Enum:
enum t { p1, p2, p3 }
Problem: can't have string enum
Object:
const t = {p1: "p1", p2: "p2", p3: "p3"}
Problem: can't strongly type a variable that should be "p1", "p2", or "p3"
I could use an object and string union types or an enum and a map but I end up repeating myself a lot. What is the proper way to get a string enum that you can iterate in typescript?