fix(typescript): handle ObjectPattern instead of ObjectExpression inside BinaryExpression, fixes #2237 (#2238)

This commit is contained in:
Lucas Azzola authored and Christopher Chedeau committed 2017-06-23 07:53:42 -07:00
1 parent b2d5366897
commit 3474056b36
7 files changed
+26 -10

No files matched your search

+3
View File
@@ -315,6 +315,9 @@ function getPrecedence(op) {
function startsWithNoLookaheadToken(node, forbidFunctionAndClass) {
node = getLeftMost(node);
switch (node.type) {
// Hack. Remove after https://github.com/eslint/typescript-eslint-parser/issues/331
case "ObjectPattern":
return !forbidFunctionAndClass;
case "FunctionExpression":
case "ClassExpression":
return forbidFunctionAndClass;
@@ -22,17 +22,16 @@ a = () => ({} = 0);
a = () => ({}, a);
a => a instanceof {};
a => ({}().b && 0)
a => ({}::b()\`\`[''].c++ && 0 ? 0 : 0)
a => ({}().c = 0)
x => ({}()())
x => ({}()\`\`)
x => ({}().b);
(a => b)::c;
a::(b => c);
a = b => c;
a = (b?) => c;
x => (y = z);
x => (y += z);
f(a => ({})) + 1;
(a => ({})) || 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(a => {}).length;
typeof (() => {});
@@ -56,17 +55,16 @@ a = () => ({} = 0);
a = () => ({}, a);
a => a instanceof {};
a => ({}().b && 0);
a => ({}::b()\`\`[""].c++ && 0 ? 0 : 0);
a => ({}().c = 0);
x => ({}()());
x => ({}()\`\`);
x => ({}().b);
(a => b)::c;
a::(b => c);
a = b => c;
a = (b?) => c;
x => (y = z);
x => (y += z);
f(a => ({})) + 1;
(a => ({})) || 0;
`;
+2 -3
View File
@@ -19,14 +19,13 @@ a = () => ({} = 0);
a = () => ({}, a);
a => a instanceof {};
a => ({}().b && 0)
a => ({}::b()``[''].c++ && 0 ? 0 : 0)
a => ({}().c = 0)
x => ({}()())
x => ({}()``)
x => ({}().b);
(a => b)::c;
a::(b => c);
a = b => c;
a = (b?) => c;
x => (y = z);
x => (y += z);
f(a => ({})) + 1;
(a => ({})) || 0;
+1 -1
View File
@@ -1 +1 @@
run_spec(__dirname, { parser: "babylon" });
run_spec(__dirname, { parser: "babylon" }, ["typescript"]);
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrows-bind.js 1`] = `
a => ({}::b()\`\`[''].c++ && 0 ? 0 : 0);
(a => b)::c;
a::(b => c);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a => ({}::b()\`\`[""].c++ && 0 ? 0 : 0);
(a => b)::c;
a::(b => c);
`;
+3
View File
@@ -0,0 +1,3 @@
a => ({}::b()``[''].c++ && 0 ? 0 : 0);
(a => b)::c;
a::(b => c);
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname, { parser: "babylon" });