const roles = ["admin", "editor"] as const;
type Role = typeof roles[number];
readonly ["admin", "editor"]The answer is readonly ["admin", "editor"]. as const turns an array literal into a readonly tuple. A tuple is a fixed-length array where each position has its own type. Each element keeps its literal type.string[] is what you get without as const, so it is wrong here. Then Role becomes "admin" | "editor". This is a common way to build a union type from a list of values.
Read more