Search Terms
Iterator.next() type, yield expression type
Suggestion
Type Iterator.next()/yield. I suggest Iterator<A, B>, where A is the input type, and B is the output type.
Mentioned in #10148 and #14883.
Required by #32283.
Alternative proposal in #32523, those this requires more drastic changes to TypeScript's type model.
Use Cases
Pretty self-explanatory; I want typed expressions. It's why I use TypeScript.
And currently, all yield ... expressions have no typing. (They are typed as any).
Examples
function* totalLength() {
let result = 0;
while (true) {
result += (yield result).length;
}
const t = totalLength();
t.next('abc'); // 0
t.next('def'); // 3
t.return(''); // 6
Checklist
My suggestion meets these guidelines:
Search Terms
Iterator.next() type, yield expression type
Suggestion
Type
Iterator.next()/yield. I suggest Iterator<A, B>, whereAis the input type, andBis the output type.Mentioned in #10148 and #14883.
Required by #32283.
Alternative proposal in #32523, those this requires more drastic changes to TypeScript's type model.
Use Cases
Pretty self-explanatory; I want typed expressions. It's why I use TypeScript.
And currently, all
yield ...expressions have no typing. (They are typed asany).Examples
Checklist
My suggestion meets these guidelines: