A readonly literal list can be the source of truth for both runtime choices and a compile-time union. It avoids maintaining a duplicate list of allowed names.
Worked example
const statuses = ["queued", "running", "done"] as const;
type Status = (typeof statuses)[number];
console.log(((s: Status) => s)("queued"));Result
queuedImplementation notes
A value imported from JSON usually has broader types than a literal declared with const assertions. Keep the source of the union under your control.
Try it yourself
Add a new member and check which dependent types expand automatically.
Open the TypeScript example →Editorial date November 20, 2025 · Published December 6, 2026