TypeScript 7 · Types
Make a literal read-only
Infer the narrowest literal types and make properties readonly.
const routes = ["/home", "/about"] as const;
type Route = (typeof routes)[number];
Official TypeScript 7 documentation
TypeScript 7 · Types
Infer the narrowest literal types and make properties readonly.
const routes = ["/home", "/about"] as const;
type Route = (typeof routes)[number];
Official TypeScript 7 documentation
Was this page helpful?