mirror of
https://github.com/swc-project/swc.git
synced 2024-11-09 23:34:20 +03:00
parent
59f6a6ffb6
commit
3252988e6a
@ -1,5 +1,14 @@
|
||||
use super::*;
|
||||
|
||||
test_exec!(
|
||||
::swc_ecma_parser::Syntax::default(),
|
||||
|_| TemplateLiteral,
|
||||
issue_231,
|
||||
"const truthy = 'a=b';
|
||||
const foo = `http://example.com/foo/bar${truthy && '?'}${truthy}`;
|
||||
console.log(foo);"
|
||||
);
|
||||
|
||||
test!(
|
||||
::swc_ecma_parser::Syntax::default(),
|
||||
|_| TemplateLiteral,
|
||||
|
@ -312,6 +312,13 @@ impl Fold<Expr> for Fixer {
|
||||
e @ Expr::Assign(..) | e @ Expr::Seq(..) | e @ Expr::Yield(..) => {
|
||||
box e.wrap_with_paren()
|
||||
}
|
||||
Expr::Bin(BinExpr { op: op_of_rhs, .. }) => {
|
||||
if op_of_rhs.precedence() < expr.op.precedence() {
|
||||
box expr.right.wrap_with_paren()
|
||||
} else {
|
||||
expr.right
|
||||
}
|
||||
}
|
||||
_ => expr.right,
|
||||
};
|
||||
|
||||
@ -604,4 +611,6 @@ function a() {
|
||||
test_fixer!(fixer_12, "(((a, b), c), d) + e;", "d + e;");
|
||||
|
||||
test_fixer!(fixer_13, "delete (((1), a), (2));", "delete 2");
|
||||
|
||||
identical!(issue_231, "'' + (truthy && '?') + truthy;");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user