Repository: swc-project/swc (rust)

Issue:
Class decorator not transformed when inside namespace
### Describe the bug

swc doesn't transform class decorators to function calls when the class is inside a namespace.

### Input code

```typescript
namespace N { @foo class C1 {} }
@foo class C2{}
```


### Config

```json
{
  "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
}
```


### Playground link

https://play.swc.rs/?version=1.2.155&code=H4sIAAAAAAAAA8tLzE0tLkhMTlXwU6hWcEjLz1dIzkksLlZwNlSorlWo5UIWMqquBQAHbCWIMAAAAA%3D%3D&config=H4sIAAAAAAAAA02PMQ6DMAxF7%2BKZoWLowNy1h7ASg6iSOLKN1Ahx9yZQEJv17fdsr%2FBRB8MKGUVJWqUlGX5hACuZ1MmcDTowrdGIQakDT44FjUVhMFloq22UiaxCpP2j7ysQmJUuxASTjiyxbQg0oSuv03JIbto3GXo0%2FNNVH%2Bc0j6WxjmMWUr3MEdMUzkVbm2W%2FtGDdH9hPesLNcQz%2BAEUDfKD5AAAA

### Expected behavior

The same emit for both `C1` and `C2`

### Actual behavior

The call to `@foo` on `C1` is emitted untransformed and is a syntax error at runtime.

### Version

1.2.155

### Additional context

_No response_

Pull request:
fix(es/decorator): Remove `noop_fold_type`

**Related issue (if exists):**


 - Closes #4021

Patch:
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 bd5837afb0..103d475b65 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);
 


Test patch:
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 0000000000..e08844a4cb
--- /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 0000000000..639683fb3a
--- /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 0000000000..19f4255d02
--- /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;