Handling Enums with FlowType -


export type size = | 'small' | 'medium' | 'large' | 'big' | 'huge'; 

defining size type gives me auto-completion in ide wherever use it:

enter image description here

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: enter image description here

yet, solution comes @ cost: screws auto-completion goodness... :( there better way handle enums in flowtype?

enter image description here


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -