The reason why it's not called "type casting" is that casting generally implies some sort of runtime support. However, type assertions are purely a compile time construct and a way for you to provide hints to the compiler on how you want your code to be analyzed.
.
Here we cast an array of possible values as the type of the Status type.
typeof STATUS[number] establishes a type context that refers to the union of all the literal types from the values found in the STATUS array.
It's important to note that you must cast the variable as a const.
Nitpick - TypeScript Deep Dive: Type Assertion vs. Casting:
.
typeof STATUS[number]
establishes a type context that refers to the union of all the literal types from the values found in theSTATUS
array.It's a const assertion similar to a type assertion.
No Discriminated Unions (alt)?