deox
deox copied to clipboard
Add Payload type utility
Are you open to adding a Payload
utility type? I think the following would be fairly useful:
const action = createActionCreator(
'FOO',
resolve => (foo: string) => resolve({ foo }),
)
// Get the payload type of this action
const FooPayload = Payload<typeof action>
Essentially I think you can do something like this but it would be better to make it generic.
type Payload = (ReturnType<typeof action>)['payload']
Sure. If anyone is interested in this, can submit a PR.