Also do the class extend parenthesis for class expressions (#403)
parent
4a47eff474
commit
e45a9b0582
|
@ -195,7 +195,7 @@ FPp.needsParens = function(assumeExpressionContext) {
|
||||||
// Add parens around the extends clause of a class. It is needed for almost
|
// Add parens around the extends clause of a class. It is needed for almost
|
||||||
// all expressions.
|
// all expressions.
|
||||||
if (
|
if (
|
||||||
parent.type === "ClassDeclaration" &&
|
(parent.type === "ClassDeclaration" || parent.type === "ClassExpression") &&
|
||||||
parent.superClass === node && (
|
parent.superClass === node && (
|
||||||
node.type === "ArrowFunctionExpression" ||
|
node.type === "ArrowFunctionExpression" ||
|
||||||
node.type === "AssignmentExpression" ||
|
node.type === "AssignmentExpression" ||
|
||||||
|
|
|
@ -54,6 +54,8 @@ function* f() {
|
||||||
// Flow has a bug parsing it.
|
// Flow has a bug parsing it.
|
||||||
// class a extends (yield 1) {}
|
// class a extends (yield 1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = class extends (++b) {}
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// \"ArrowFunctionExpression\"
|
// \"ArrowFunctionExpression\"
|
||||||
class a extends (() => {
|
class a extends (() => {
|
||||||
|
@ -112,5 +114,7 @@ function* f() {
|
||||||
// Flow has a bug parsing it.
|
// Flow has a bug parsing it.
|
||||||
// class a extends (yield 1) {}
|
// class a extends (yield 1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = class extends (++b) {};
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -53,3 +53,5 @@ function* f() {
|
||||||
// Flow has a bug parsing it.
|
// Flow has a bug parsing it.
|
||||||
// class a extends (yield 1) {}
|
// class a extends (yield 1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = class extends (++b) {}
|
||||||
|
|
Loading…
Reference in New Issue