← Fullstack with Vue.jsQuestion 24 of 62
What does "as const" do in TypeScript?
📘 Explanation
as const narrows values to their literal types, makes properties readonly, and prevents type widening, as seen when an array becomes a readonly tuple of literal numbers. It doesn't create a runtime constant, convert values to immutable primitives at runtime, or deeply freeze objects—those effects don't happen, since as const is purely a compile-time type annotation.
Related questions
← PreviousNo login needed