Created
January 24, 2022 13:22
-
-
Save i-mighty/cfbf67d19c63a248b4d405e96057c1ea to your computer and use it in GitHub Desktop.
Unwrap Return type from Promises
This file contains hidden or 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
export type Unwrap<T> = T extends Promise<infer U> | |
? U | |
: T extends (...args: any) => Promise<infer U> | |
? U | |
: T extends (...args: any) => infer U | |
? U | |
: T; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment