the-dr-lazy / deox

Functional Type-safe Flux Standard Utilities
https://deox.js.org
MIT License
206 stars 12 forks source link

Add Payload type utility #173

Open sanbornhilland opened 3 years ago

sanbornhilland commented 3 years ago

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']
the-dr-lazy commented 3 years ago

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