Closed
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
- Generator
- Generator loop
- Generator for
- Generator iterator
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
const gen = function* () {
yield 2;
yield 3;
}
const genInst = gen();
for (let i of genInst) {
console.log(i);
}
Expected behavior:
- No error is thrown
- console.log should output yield value 2, 3
- Just try it in Chrome debugger
Actual behavior:
- TSC: throw type error
error TS2569: Type 'IterableIterator<2 | 3>' is not an array type or a string type.
Playground Link:
Related Issues: