Skip to content

Instantly share code, notes, and snippets.

@mrehayden1
Last active September 5, 2018 08:39
Show Gist options
  • Save mrehayden1/d58809b83f83d717c42e3b6ae8f82c6e to your computer and use it in GitHub Desktop.
Save mrehayden1/d58809b83f83d717c42e3b6ae8f82c6e to your computer and use it in GitHub Desktop.
Discriminated Union
enum ItemType {
BunBottom,
BunTop,
Burger
}
type Cooked = [ number, number ]
type Item = {
type: ItemType.BunBottom
} | {
type: ItemType.BunTop
} | {
type: ItemType.Burger,
cooked: Cooked
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment