Skip to content

Instantly share code, notes, and snippets.

@gabrielseco
Last active October 28, 2019 09:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gabrielseco/30d44b090e6e039efb6ae561a3cafa1c to your computer and use it in GitHub Desktop.
Flow Recipes

How to make Union Types from Objects

const FilterA = Object.freeze({
  ALL: 'ALL',
  COMPLETED: 'COMPLETED',
  UNCOMPLETED: 'UNCOMPLETED'
});

type FilterTypeA = $Values<typeof FilterA>;


let a: FilterTypeA = FilterA.ALL; //OK
a = 'COMPLETED'; //OK
a = 'foo' // Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment