recursive return type for deterministic generators #27267
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
If a generator neither yields inside a loop nor defers to another generator, it's considered deterministic. For any given number of
next
calls, the compiler could theoretically reduce the generator to the exact type of its next yield. Of course, because generators are mutable, this isn't true. But what if I'm using a library that allows for immutable generators? For everynext
call, a new generator is returned. Maybe it should be possible to introspect the order of yields in a deterministic generator, and use that to deduce a recursive type structure that represents an immutable generator.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: