Top "Union-types" questions

This is a tag to discuss the Union Type feature as seen in languages such as TypeScript, Ceylon or F#.

What does "keyof typeof" mean in TypeScript?

Example: Explain to me what keyof typeof means in TypeScript enum ColorsEnum { white = '#ffffff', black = '#000000', } type Colors = …

typescript typeof union-types keyof
mypy, type hint: Union[float, int] -> is there a Number type?

mypy is really handy and catches a lot of bugs, but when I write "scientific" applications, I often end up …

python type-hinting mypy union-types
How to define string literal union type from constants in Typescript

I know I can define string union types to restrict variables to one of the possible string values: type MyType = …

typescript string-literals typescript3.0 union-types
How to type a Typescript array to accept only a specific set of values?

I am writing a type declaration file for a library I do not control. One of the methods accepts an …

arrays typescript union-types type-declaration