Ensure parens on NewExpression with function callee (#282)

This commit is contained in:
Brian Ng authored and Christopher Chedeau committed 2017-01-17 19:45:56 -08:00
1 parent 8229355508
commit b94b86331f
6 files changed
+15 -4

No files matched your search

+3
View File
@@ -378,6 +378,9 @@ FPp.needsParens = function(assumeExpressionContext) {
case "UnaryExpression":
return true;
case "NewExpression":
return name === "callee";
default:
return isBinary(parent);
}
@@ -32,6 +32,7 @@ typeof (() => {});
export default (() => {})();
(() => {})()\`\`;
(() => {})\`\`;
new (() => {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(a => {
}).length;
@@ -43,6 +44,8 @@ export default (() => {
})()\`\`;
(() => {
})\`\`;
new (() => {
})();
"
`;
@@ -3,3 +3,4 @@ typeof (() => {});
export default (() => {})();
(() => {})()``;
(() => {})``;
new (() => {});
+4 -4
View File
@@ -192,8 +192,8 @@ var e = async function() {
var et = async function<T>(a: T) {
};
var n = new async function() {
}();
var n = new (async function() {
})();
var o = {
async m() {
@@ -516,9 +516,9 @@ var et = async function<T>(a: T) {
await 1;
};
var n = new async function() {
var n = new (async function() {
await 1;
}();
})();
var o = {
async m() {
@@ -369,6 +369,7 @@ typeof (function() {});
export default (function() {})();
(function() {})()\`\`;
(function() {})\`\`;
new (function() {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(function() {
}).length;
@@ -380,6 +381,8 @@ export default (function() {
})()\`\`;
(function() {
})\`\`;
new (function() {
})();
"
`;
+1
View File
@@ -3,3 +3,4 @@ typeof (function() {});
export default (function() {})();
(function() {})()``;
(function() {})``;
new (function() {});