mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
fix(es/codegen): Preserve more parens (#6268)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/6266.
This commit is contained in:
parent
d2dc90bc69
commit
c3184463f1
@ -0,0 +1,6 @@
|
||||
function test(node) {
|
||||
return (
|
||||
// comment from the source code
|
||||
(_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.filter((m) => !ts.isDecorator(m))
|
||||
);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
function test(node) {
|
||||
return(// comment from the source code
|
||||
(_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.filter(function(m) {
|
||||
return !ts.isDecorator(m);
|
||||
}));
|
||||
}
|
@ -2736,6 +2736,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
Expr::Cond(e) => {
|
||||
if self.has_leading_comment(&e.test) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Expr::Seq(e) => {
|
||||
if let Some(e) = e.exprs.first() {
|
||||
if self.has_leading_comment(e) {
|
||||
@ -2744,6 +2750,22 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
Expr::Assign(e) => {
|
||||
if let Some(cmt) = self.comments {
|
||||
let lo = e.span.lo;
|
||||
|
||||
if cmt.has_leading(lo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(e) = e.left.as_expr() {
|
||||
if self.has_leading_comment(e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user