Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground: Add toggle to enable downlevelIteration flag #18209

Closed
alexsapps opened this issue Sep 1, 2017 · 2 comments
Closed

Playground: Add toggle to enable downlevelIteration flag #18209

alexsapps opened this issue Sep 1, 2017 · 2 comments
Assignees
Labels
Website Deprecated - please forward issue to microsoft/TypeScript-Website

Comments

@alexsapps
Copy link

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.

@mhegazy mhegazy added the Docs The issue relates to how you learn TypeScript label Sep 5, 2017
@DanielRosenwasser DanielRosenwasser added Website Deprecated - please forward issue to microsoft/TypeScript-Website and removed Docs The issue relates to how you learn TypeScript labels Oct 18, 2017
@NN---
Copy link

NN--- commented Feb 25, 2019

As a workaround you can use: https://typescript-play.js.org

E.g. for (const a of [1,2]) {}

@orta
Copy link
Contributor

orta commented Jul 10, 2019

This should be working now that we've integrated typescript-play 👍

@orta orta closed this as completed Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Website Deprecated - please forward issue to microsoft/TypeScript-Website
Projects
None yet
Development

No branches or pull requests

5 participants