Closed
Description
When I click "Options" there are a few compiler flags that the user can check to enable. Adding "downlevelIteration" as one of the options would let me try out custom generators when transpiling to ES5.
Currently when trying to run the fibonacci generator code sample from the for...of docs:
function* fibonacci() { // a generator function
let [prev, curr] = [0, 1];
while (true) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
for (let n of fibonacci()) {
console.log(n);
// truncate the sequence at 1000
if (n >= 1000) {
break;
}
}
the playground shows this error:
Type 'IterableIterator<number>' is not an array type or a string type.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
NN--- commentedon Feb 25, 2019
As a workaround you can use: https://typescript-play.js.org
E.g. for (const a of [1,2]) {}
orta commentedon Jul 10, 2019
This should be working now that we've integrated typescript-play 👍