TypeScript Output Prediction Easy +10 XP
Const Assertion
What is the type of colors?
TypeScriptRead-only
const colors = ["red", "blue"] as const; // What is typeof colors?
What is the output?
Show answer and explanation
Answer: readonly ["red", "blue"]
'as const' creates a readonly tuple with literal types instead of a mutable string array.
Hint: 'as const' makes things immutable and literal.
What this challenge tests
Output Prediction in TypeScript: const-assertion, readonly.