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

Generator with Array Spread #11970

Closed
johnlindquist opened this issue Nov 1, 2016 · 1 comment
Closed

Generator with Array Spread #11970

johnlindquist opened this issue Nov 1, 2016 · 1 comment

Comments

@johnlindquist
Copy link

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
@aluanhaddad
Copy link
Contributor

With "target": "es5" this is the intentional. Arguably it is undesirable and there are a number of issues relating to that and to down level generate or support in general.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants