Explore Library
Code QuizBeginner

Value Outside Literal Union

Assigning a value not present in a string literal union produces a type error.

Codetypescript
type Alignment = "left" | "center" | "right";

let align: Alignment = "middle";
console.log(align);

What is the bug in this literal union assignment?