Skip to content

Commit

Permalink
emit parens to disambiguate between 'new Thing()' and 'new Thing()' (c…
Browse files Browse the repository at this point in the history
…loses #1159)
  • Loading branch information
fabiosantoscode committed Mar 4, 2022
1 parent 2142ddb commit a6c87ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/output.js
Expand Up @@ -1098,7 +1098,8 @@ function OutputStream(options) {
var p = output.parent();
if (this.args.length === 0
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|| p instanceof AST_Call && p.expression === this)) // (new foo)(bar)
|| p instanceof AST_Call && p.expression === this
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
return true;
});

Expand Down
7 changes: 7 additions & 0 deletions test/compress/template-string.js
Expand Up @@ -940,3 +940,10 @@ special_chars_in_string: {
var template=`foo \`;\n\`\${any} ${any} bar`;
}
}

template_string_new_parens: {
input: {
new Thing()``
}
expect_exact: "(new Thing)``;"
}

0 comments on commit a6c87ad

Please sign in to comment.