From 0c8c3d7d51e49ad9050224a8647ebc55a0262b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 15 Mar 2022 18:14:47 +0900 Subject: [PATCH] fix(es/decorator): Remove `noop_fold_type` (#4022) --- .../decorators/issue-4021/input/.swcrc | 23 +++++++++++++++++++ .../decorators/issue-4021/input/index.ts | 2 ++ .../decorators/issue-4021/output/index.ts | 8 +++++++ .../src/decorators/legacy/mod.rs | 4 +--- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 crates/swc/tests/fixture/decorators/issue-4021/input/.swcrc create mode 100644 crates/swc/tests/fixture/decorators/issue-4021/input/index.ts create mode 100644 crates/swc/tests/fixture/decorators/issue-4021/output/index.ts diff --git a/crates/swc/tests/fixture/decorators/issue-4021/input/.swcrc b/crates/swc/tests/fixture/decorators/issue-4021/input/.swcrc new file mode 100644 index 00000000000..e08844a4cbf --- /dev/null +++ b/crates/swc/tests/fixture/decorators/issue-4021/input/.swcrc @@ -0,0 +1,23 @@ +{ + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": false, + "decorators": true + }, + "target": "es2022", + "loose": false, + "transform": { + "legacyDecorator": true, + "decoratorMetadata": false + }, + "minify": { + "compress": false, + "mangle": false + } + }, + "module": { + "type": "es6" + }, + "minify": false +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/decorators/issue-4021/input/index.ts b/crates/swc/tests/fixture/decorators/issue-4021/input/index.ts new file mode 100644 index 00000000000..639683fb3a5 --- /dev/null +++ b/crates/swc/tests/fixture/decorators/issue-4021/input/index.ts @@ -0,0 +1,2 @@ +namespace N { @foo class C1 { } } +@foo class C2 { } \ No newline at end of file diff --git a/crates/swc/tests/fixture/decorators/issue-4021/output/index.ts b/crates/swc/tests/fixture/decorators/issue-4021/output/index.ts new file mode 100644 index 00000000000..19f4255d02d --- /dev/null +++ b/crates/swc/tests/fixture/decorators/issue-4021/output/index.ts @@ -0,0 +1,8 @@ +var _class, _class1; +var N; +(function(N) { + let C1 = _class = foo((_class = class C1 { + }) || _class) || _class; +})(N || (N = {})); +let C2 = _class1 = foo((_class1 = class C2 { +}) || _class1) || _class1; diff --git a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs index bd5837afb0c..103d475b659 100644 --- a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs +++ b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs @@ -10,7 +10,7 @@ use swc_ecma_utils::{ prop_name_to_expr, prop_name_to_expr_value, quote_ident, replace_ident, undefined, ExprFactory, ModuleItemLike, StmtLike, }; -use swc_ecma_visit::{noop_fold_type, Fold, FoldWith, Visit, VisitWith}; +use swc_ecma_visit::{Fold, FoldWith, Visit, VisitWith}; use self::metadata::{Metadata, ParamMetadata}; use super::{contains_decorator, DecoratorFinder}; @@ -86,8 +86,6 @@ impl Visit for Legacy { /// TODO: VisitMut impl Fold for Legacy { - noop_fold_type!(); - fn fold_decl(&mut self, decl: Decl) -> Decl { let decl: Decl = decl.fold_children_with(self);