deox icon indicating copy to clipboard operation
deox copied to clipboard

Add Payload type utility

Open sanbornhilland opened this issue 3 years ago • 1 comments

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']

sanbornhilland avatar Jun 10 '21 14:06 sanbornhilland

Sure. If anyone is interested in this, can submit a PR.

the-dr-lazy avatar Jun 11 '21 05:06 the-dr-lazy