Type inference for async generators #44264
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
It would be amazing if typescript could infer types from async generators.
The following is valid javascript, thus, I think, it should be valid typescript and type of
x
should be inferred.Today it fails with
Parameter 'x' implicitly has 'any' type.
🔍 Search Terms
async generator, async iterator, type inference, infer types
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Treat type of
x
as "any async iterator would do" thus including any async generator function.📃 Motivating Example
My own use... forever/background (async) processes/
💻 Use Cases
Today, I need to type this explicitly, which is unnecessarily verbose.
In the long run, it would allow composing async functions same as type inference helps composing plain functions today.
I get it that type inference for async iterables/iterators/generators opens a huge can of worms, like:
The text was updated successfully, but these errors were encountered: