-
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
Preserve ordered yield types when no logic is involved #43150
Comments
#42033 looks very close, yes. |
@RyanCavanaugh I think this one could be a very simple "gateway" implementation for other issues like that one which cover more cases. This might be just enough of a catalyst to justify making the minimal changes to the type system needed to get the ball rolling for other features. |
@RyanCavanaugh The reason I think so btw is because I saw in #32523 (comment) that it's the missing relationship between TYield and TNext that's the show-stopper, and this feature request is just for the specific use-case when you can clearly see that there's no yields inside any branching/logic, so that you can safely know that it's just a fixed list of types. It might even be possible to use tuple types to achieve this. At which point, the groundwork is laid for the more complex use-cases. Anyway just an idea. |
Oh. Looks like that issue was talking about the type of the value returned to the yield, not the value returned from the yield. Oops. |
Honestly I'm not even sure what the use-case is for this anymore. I certainly don't currently have one. Worth closing imo. |
Suggestion
π Search Terms
yield ordered return types
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Make types more definite for each yielded return value in a generator function
See also https://stackoverflow.com/questions/66538431/function-chain-factory-in-typescript-preserving-input-output-types
π Motivating Example
Right now, if I do this:
Right now this gives:
But since there's no logic/branching/etc, it would be more helpful to me to have:
π» Use Cases
Sometimes I want to use a function generator to represent a series of steps that I want to examine (whether at runtime or during testing, etc) before deciding whether to continue. In other words, I want to break up a function into a series of "pauseable" steps.
The text was updated successfully, but these errors were encountered: