Skip to content

Playground: Add toggle to enable downlevelIteration flag #18209

Closed
@alexsapps

Description

@alexsapps

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.

Activity

added
DocsThe issue relates to how you learn TypeScript
on Sep 5, 2017
added
WebsiteDeprecated - please forward issue to microsoft/TypeScript-Website
and removed
DocsThe issue relates to how you learn TypeScript
on Oct 18, 2017
NN---

NN--- commented on Feb 25, 2019

@NN---
orta

orta commented on Jul 10, 2019

@orta
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

WebsiteDeprecated - please forward issue to microsoft/TypeScript-Website

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @orta@NN---@DanielRosenwasser@alexsapps@mhegazy

      Issue actions

        Playground: Add toggle to enable downlevelIteration flag · Issue #18209 · microsoft/TypeScript