From 54e0bfd87831c6269f9f34d6bc9e370a73936210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 3 Aug 2020 00:47:23 +0900 Subject: [PATCH] Update swc_ecma_utils (#927) --- .../transforms/tests/typescript_strip.rs | 16 ++++++++++++++ ecmascript/utils/Cargo.toml | 2 +- ecmascript/utils/src/lib.rs | 22 +++++++++---------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ecmascript/transforms/tests/typescript_strip.rs b/ecmascript/transforms/tests/typescript_strip.rs index 3a7da19afe4..4e979eb852f 100644 --- a/ecmascript/transforms/tests/typescript_strip.rs +++ b/ecmascript/transforms/tests/typescript_strip.rs @@ -679,3 +679,19 @@ to!( }", "export abstract class Kernel {}" ); + +to!( + issue_926, + "class A extends Object { + constructor(public a, private b) { + super(); + } +}", + "class A extends Object { + constructor(a, b){ + super(); + this.a = a; + this.b = b; + } +}" +); diff --git a/ecmascript/utils/Cargo.toml b/ecmascript/utils/Cargo.toml index aa5ac134170..870ff4ef7f1 100644 --- a/ecmascript/utils/Cargo.toml +++ b/ecmascript/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swc_ecma_utils" -version = "0.16.0" +version = "0.16.1" authors = ["강동윤 "] license = "Apache-2.0/MIT" repository = "https://github.com/swc-project/swc.git" diff --git a/ecmascript/utils/src/lib.rs b/ecmascript/utils/src/lib.rs index 47cb2572711..1bd6108b295 100644 --- a/ecmascript/utils/src/lib.rs +++ b/ecmascript/utils/src/lib.rs @@ -1458,20 +1458,20 @@ pub fn prepend_stmts( ) { let idx = to .iter() - .position(|item| match item.as_stmt() { - Some(&Stmt::Expr(ExprStmt { ref expr, .. })) - if match &**expr { - Expr::Lit(Lit::Str(..)) => true, + .position(|item| { + match item.as_stmt() { + Some(&Stmt::Expr(ExprStmt { ref expr, .. })) => match &**expr { + Expr::Lit(Lit::Str(..)) => return false, Expr::Call(expr) => match expr.callee { - ExprOrSuper::Super(_) => true, - ExprOrSuper::Expr(_) => false, + ExprOrSuper::Super(_) => return false, + ExprOrSuper::Expr(_) => {} }, - _ => false, - } => - { - false + _ => {} + }, + _ => {} } - _ => true, + + true }) .unwrap_or(to.len());