Skip to content

Generator with Array Spread #11970

Closed
Closed
@johnlindquist

Description

@johnlindquist

Version 2.1.0-dev.20161031

const g = function*(){
    yield 1;
}

console.log([...g()]);

Compiles to the following which throws an error (treating the generator as an array, not an iterable):

var g = function* () {
    yield 1;
};
console.log(g().slice());
//# sourceMappingURL=build.js.map

Possible solution using Array.from:

var g = function* () {
    yield 1;
};
console.log(Array.from(g()).slice());
//# sourceMappingURL=build.js.map

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