Created
January 10, 2020 00:25
-
-
Save enjoylife/945bc2686390c44eee0b59d9209411da to your computer and use it in GitHub Desktop.
enumMap flow util
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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