From 7a8ad8826a0072a53993977e68b00ccabe525d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 14 Jul 2021 22:43:17 +0900 Subject: [PATCH] fix(es/transforms): Fix fixer (#1919) swc_ecma_transforms_base: - `fixer`: Allow using await expressions as a callee of a new expression. --- ecmascript/transforms/base/Cargo.toml | 2 +- ecmascript/transforms/base/src/fixer.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ecmascript/transforms/base/Cargo.toml b/ecmascript/transforms/base/Cargo.toml index 8b7d35b86d5..f293cee57bf 100644 --- a/ecmascript/transforms/base/Cargo.toml +++ b/ecmascript/transforms/base/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_base" repository = "https://github.com/swc-project/swc.git" -version = "0.22.0" +version = "0.22.1" [dependencies] fxhash = "0.2.1" diff --git a/ecmascript/transforms/base/src/fixer.rs b/ecmascript/transforms/base/src/fixer.rs index c431b02af2a..f2c7c0cafc0 100644 --- a/ecmascript/transforms/base/src/fixer.rs +++ b/ecmascript/transforms/base/src/fixer.rs @@ -78,6 +78,7 @@ impl VisitMut for Fixer<'_> { node.callee.visit_mut_with(self); match *node.callee { Expr::Call(..) + | Expr::Await(..) | Expr::Bin(..) | Expr::Assign(..) | Expr::Seq(..) @@ -1241,4 +1242,9 @@ var store = global[SHARED] || (global[SHARED] = {}); identical!(new_call, "new (getCtor())"); test_fixer!(new_member_1, "new obj.ctor()", "new obj.ctor()"); test_fixer!(new_member_2, "new (obj.ctor)", "new obj.ctor"); + + identical!( + new_await_1, + "async function foo() { new (await getServerImpl())(options) }" + ); }