TypeScript · Generics and utility types
as const
Makes literals readonly and narrow instead of widening to string[].
Syntax
["a", "b"] as constExample
Example
const roles = ["admin", "learner"] as const; type Role = typeof roles[number];
More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.