const ACTION1: "ACTION1" = "ACTION1"; const ACTION2: "ACTION2" = "ACTION2"; const ACTIONS = { a: () => ({ type: ACTION1, payload: { num: 1 } }), b: () => ({ type: ACTION2, payload: { str: "A" } }) }; function reducer(action: $Values<$ObjMap<typeof ACTIONS, <R>(() => R) => R>>): string { switch (action.type) { // any | "ACTION1" | "ACTION2" case ACTION1: return "" + action.payload.num; // any | number case ACTION2: return "" + action.payload.str; // any | string default: ;(action.type: empty) return ""; } }
https://flow.org/try/#0MYewdgzgLgBAggYQCoEkDyA5AjALhgIkVUy3xgF4Cj1t8BuAKFElmswCY9Dkb2zLuxDH0ZNw0eD0wBlCjADeDGDACGeABQBKCgD4Y6+TCgBPAA4BTPG2wAaGKZXGANiBUATPIbABXALZ4sGABfYM0bJRgAIw1tcj0DIzNLSSF2OwdnVw8FGGgAJy44MhCgzQYg0QAzbzBgKABLcBg88zdvYHM89RU6xrA8ABIANRUnb3MIAB4BtEiAKwBZFVNJkwsQSpSaaTtJgCUddS1dGD3YvQOdTTx8+rAAcwUInobwCIgAd3qoYAALfRefQAdGtzNpFMplMAVBBzFsSDgIpDmuYoN48mACGQANSqXrgIEZFzuIE+XyMZHQ2Hw4SI5HKFpojFYmC4wEEolZIH5CmQtzmSoqbxOKB0+l0br4sAgpJ4cy+UwmMr0lFMzH4egRILlBhAA
Что не так с этим кодом?