Created
October 16, 2022 00:21
-
-
Save cefn/8f88ceb1b048ea450c01eaab3459b7f7 to your computer and use it in GitHub Desktop.
Infer TReturn type from Generator or AsyncGenerator
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 Returned< | |
G extends Generator<any, any, any> | AsyncGenerator<any, any, any> | |
> = G extends Generator<any, infer TReturn, any> | |
? TReturn | |
: G extends AsyncGenerator<any, infer AsycTReturn, any> | |
? AsycTReturn | |
: never; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment