Skip to content

yield*: Delegating to other generators is not an array #17585

Closed
@JPeer264

Description

@JPeer264

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)
This issue might be a duplicate of #17276 (but it addresses another issue)

Code

The following example is straight out of the MDN docs and copied it right into TS Playground:

function* g1() {
  yield 2;
  yield 3;
  yield 4;
}

function* g2() {
  yield 1;
  yield* g1(); // <- gives an error: "Type 'IterableIterator<>' is not an array type"
  yield 5;
}

var iterator = g2();

Expected behavior:
Expect that the error won't appear.

Actual behavior:
Typescript throws an error that g1() is not an array type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions