Skip to content

Instantly share code, notes, and snippets.

@enjoylife
Created January 10, 2020 00:25
Show Gist options
  • Save enjoylife/945bc2686390c44eee0b59d9209411da to your computer and use it in GitHub Desktop.
Save enjoylife/945bc2686390c44eee0b59d9209411da to your computer and use it in GitHub Desktop.
enumMap flow util
export type EnumNames = 'A' | 'B' | 'C';
export type EnumMap<K: string, V, O: Object = *> = O & {
[K]: V & $ElementType<O, K>,
};
export type SpecificMap = EnumMap<EnumNames, any>;
const cbNames: EnumMap<EnumNames, (any) => void> = {
A: v => v,
B: v => v.prop,
C: () => {},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment