Handling Enums with FlowType -
export type size = | 'small' | 'medium' | 'large' | 'big' | 'huge'; defining size type gives me auto-completion in ide wherever use it:
yet, want make use of these values inside of component: let's dropdown menu w/ available size values.
in order achieve maintaining sizes object out of can extract size flowtype leveraging $keys:
export const sizes = { small: 'small', medium: 'medium', large: 'large', big: 'big', huge: 'huge', }; export type size = $keys<typeof sizes>; it kind of works in points out invalid values prop: 
yet, solution comes @ cost: screws auto-completion goodness... :( there better way handle enums in flowtype?


Comments
Post a Comment