Skip to content

Instantly share code, notes, and snippets.

@alexeychikk
Created October 28, 2019 11:28
Show Gist options
  • Save alexeychikk/f3629ca25fd2e1f29f6784256e5fbe1c to your computer and use it in GitHub Desktop.
Save alexeychikk/f3629ca25fd2e1f29f6784256e5fbe1c to your computer and use it in GitHub Desktop.
Thunkify
// tslint:disable: no-any
export type Thunkify<
Actions extends { [key: string]: (...args: any) => any }
> = {
[actionKey in keyof Actions]: ReturnType<Actions[actionKey]> extends ((
...args: any
) => Promise<any>)
?
| ((
...args: Parameters<Actions[actionKey]>
) => ReturnType<ReturnType<Actions[actionKey]>>)
| Actions[actionKey]
: Actions[actionKey]
};
// tslint:enable: no-any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment