diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 1e206ac50e..d86cc05c20 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -526,7 +526,7 @@ defineType("ObjectProperty", { }, }, value: { - validate: assertNodeType("Expression"), + validate: assertNodeType("Expression", "Pattern", "RestElement"), }, shorthand: { validate: assertValueType("boolean"), diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index ccc83f665b..8ad737b00b 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -31,4 +31,28 @@ suite("validators", function () { assert(t.isValidIdentifier("await") === false); }); }); + + suite("patterns", function () { + it("allows nested pattern structures", function () { + const pattern = t.objectPattern([ + t.objectProperty( + t.identifier("a"), + t.objectPattern([ + t.objectProperty( + t.identifier("b"), + t.stringLiteral("foo") + ), + t.objectProperty( + t.identifier("c"), + t.arrayPattern([ + t.identifier("value"), + ]) + ), + ]) + ), + ]); + + assert(t.isNodesEquivalent(pattern, pattern) === true); + }); + }); });