-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Support spreading and destructuring of iterators in ES6 #2498
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
Conversation
// Normally, in ES6, the implied type of an array binding pattern with a rest element is | ||
// an iterable. However, there is a requirement in our grammar checker that all rest | ||
// parameters be array types. To satisfy this, we have an exception to the rule that | ||
// says the type of an array binding pattern with a rest element is an array type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an odd requirement given that the grammar only says this:
RestParameter:
... Identifier TypeAnnotation_opt
I don't see why, at grammar check time, we'd care if the parameter was an array type or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the type system, not the grammar checker. I will fix the comment
To see a design proposal, see #1900 (comment) |
forgot to approve 👍 |
Support spreading and destructuring of iterators in ES6
This adds support for a few things:
I will also add that tuples are relatively unaffected. If you declare something to be a tuple, you can still only assign a tuple to it. And if you have an array binding pattern with no rest element, its implied type is a tuple. So the following does give you an error: