Created
October 28, 2019 11:28
-
-
Save alexeychikk/f3629ca25fd2e1f29f6784256e5fbe1c to your computer and use it in GitHub Desktop.
Thunkify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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