-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yield Overrides #47548
base: main
Are you sure you want to change the base?
Yield Overrides #47548
Conversation
@typescript-bot pack this |
Heya @andrewbranch, I've started to run the tarball bundle task on this PR at 9fc3cc5. You can monitor the build here. |
Sorry about that, tests should be fixed; can you try to re-run the pack? |
@typescript-bot pack this |
Heya @andrewbranch, I've started to run the tarball bundle task on this PR at c9f8bb2. You can monitor the build here. |
Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
/** | ||
* Marker for yield expressions return types | ||
*/ | ||
interface YieldType<T> { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use type YieldType<T> = intrinsic;
? (see #46836 for ThisType
above)
I'd love to help in anyway possible to get this across the finish line. Is there anything I can do to help? |
It should already be ok apart from a couple of extra tests; next blocker is to find someone to champion it in the TS team. |
How can we find someone to champion this PR? |
To be clear, nobody on the TypeScript team ever indicated that this approach to solving this problem would be mergeable. @arcanis wrote it as an experiment purely to help the discussion in #43632 along. Given the discussion there, I personally feel that this is not the right approach—this is essentially just a type assertion, but piggy-backing on non-type-assertion syntax in such a way that nobody will recognize that it’s just as unsafe. The next step is not finding someone to champion this PR; we are still on the very first step: exploring possible solutions that could be driven to consensus. |
This PR implements #43632 and provides a way to annotate values in such a way that, when yielded, they return a specific other type. This allows libraries built around generators to provide proper typings:
Fixes #43632
cc @andrewbranch for the playground link