Created
October 5, 2021 16:34
-
-
Save CCColda/4251981e652164b4195ec78bcefbb8b7 to your computer and use it in GitHub Desktop.
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
/** | |
* @brief Gives the Promise + non-Promise variant of a function | |
* @example MaybePromise<(x: number, y: string | number) => Date> = | |
* ((x: number, y: string | number) => Date) | ((x: number, y: string | number) => Promise<Date>) | |
* @author COlda | |
*/ | |
type MaybePromise<T extends (...args: any) => any> = T | (T extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : never); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment