Fix missing parenthesis for typeof and arrow functions (#249)

master
Brian Ng 2017-01-16 11:08:46 -06:00 committed by Christopher Chedeau
parent 1c8414e894
commit 86c65d1f81
3 changed files with 11 additions and 4 deletions

View File

@ -371,11 +371,14 @@ FPp.needsParens = function(assumeExpressionContext) {
return true;
}
if (parent.type === "MemberExpression") {
return true;
}
switch (parent.type) {
case "MemberExpression":
case "UnaryExpression":
return true;
return isBinary(parent);
default:
return isBinary(parent);
}
case "ClassExpression":
return parent.type === "ExpressionStatement";

View File

@ -27,9 +27,12 @@ var ident = <T>(x: T): T => x;
exports[`test arrow_function_expression.js 1`] = `
"(a => {}).length
typeof (() => {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(a => {
}).length;
typeof (() => {
});
"
`;

View File

@ -1 +1,2 @@
(a => {}).length
typeof (() => {});