Fix binary expression instanceof in arrow function expression (#913)
* Add fix for parens of BinaryExpression with instanceof op embedded into ArrowFunctionExpression.
* Add new test 🚀.
master
parent
b91d6384a6
commit
4dde054bb3
|
@ -305,6 +305,13 @@ FPp.needsParens = function(assumeExpressionContext) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
node.operator === "instanceof" &&
|
||||
parent.type === "ArrowFunctionExpression"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
case "LogicalExpression":
|
||||
switch (parent.type) {
|
||||
case "CallExpression":
|
||||
|
|
|
@ -9,6 +9,7 @@ export default (() => {})();
|
|||
new (() => {});
|
||||
if ((() => {}) ? 1 : 0) {}
|
||||
let f = () => ({}())
|
||||
let a = () => ({} instanceof a);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(a => {}).length;
|
||||
typeof (() => {});
|
||||
|
@ -19,6 +20,7 @@ new (() => {})();
|
|||
if ((() => {}) ? 1 : 0) {
|
||||
}
|
||||
let f = () => ({}());
|
||||
let a = () => ({} instanceof a);
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
@ -6,3 +6,4 @@ export default (() => {})();
|
|||
new (() => {});
|
||||
if ((() => {}) ? 1 : 0) {}
|
||||
let f = () => ({}())
|
||||
let a = () => ({} instanceof a);
|
||||
|
|
Loading…
Reference in New Issue