Think of it as a simplified version of an enum
...
The code below will successfully compile:
testOptions: "Undecided" | "Yes" | "No" = "Undecided";
testOptions: "Undecided" | "Yes" | "No" = "Yes";
testOptions: "Undecided" | "Yes" | "No" = "No";
testOptions: "a" | "b" | "c" = "a";
However, this snippet will not compile:
testOptions: "Undecided" | "Yes" | "No" = "xxx";
testOptions: "a" | "b" | "c" = "xxx";
This is because "xxx" is not included in the specified type declaration.
Contrasted with a traditional enum:
enum MyEnum{
Undecided= 1,
Yes,
No
}
testOptions:MyEnum = MyEnum.Yes; <-- much clearer and straightforward to interpret