Correct the validator for ArrayPattern (#5722)

The elements of the `elements` array should be either `Identifier`, `Pattern` or `RestElement`, but the validator was requiring `Expression`. It happened to work for `Identifier` since an `Identifier` is an `Expression`, but not for the other possible pattern elements.
This commit is contained in:
Diogo Franco 2017-05-10 10:50:01 +09:00 committed by GitHub
parent 5633e3c4f6
commit 899a754bef

View File

@ -29,7 +29,7 @@ defineType("ArrayPattern", {
aliases: ["Pattern", "LVal"],
fields: {
elements: {
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression"))),
validate: chain(assertValueType("array"), assertEach(assertNodeType("Identifier", "Pattern", "RestElement"))),
},
decorators: {
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),