Skip to content

Instantly share code, notes, and snippets.

@cefn
Created October 16, 2022 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cefn/f27f4b29f1f2029c7a692d7955b29461 to your computer and use it in GitHub Desktop.
Save cefn/f27f4b29f1f2029c7a692d7955b29461 to your computer and use it in GitHub Desktop.
Inference of T yielded by Generator or AsyncGenerator
export type Yielded<
G extends Generator<any, any, any> | AsyncGenerator<any, any, any>
> = G extends Generator<infer T, any, any>
? T
: G extends AsyncGenerator<infer AsyncT, any, any>
? AsyncT
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment