Repository: swc-project/swc (rust)

Issue:
Reflect metadata "design:returntype" is undefined 
### Describe the bug

When using reflect-metadata, the built-in metadata "design:returntype" is always undefined.
The following code demonstrates this well.

### Input code

```typescript
import 'reflect-metadata'

let returnType: unknown;

function decorator(target: any, key: string | symbol, descriptor: PropertyDescriptor): void {
    returnType = Reflect.getMetadata('design:returntype', target, key);
}

class Foo {
    @decorator
    public foo(x: string): string {
        return 'foo';
    }
}

console.log(returnType);
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": true
    },
    "target": "es2020"
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": true
}
```


### Playground link

[Playground](https://play.swc.rs/?version=1.2.124&code=H4sIAAAAAAAAA0WOQWrEMAxF9z6Fdk4gnQM4FLoo3RVK6QU8jhLMOJaRlc6Ydu5ek0wT7SSe%2Fn9%2BTsQCmnEM6ORpRrGDFauVCijAKAvHr5LQwBIvka6xV2pcohNPEQZ0xFaIG7E8oRiwsXRwwWIgC%2Fs4wS%2FkMp8pdBXOjn2qtIEPpoQs5XW%2FtQa%2ByQ%2Fwo6DO0QvP8Lm5nWrB%2B0Ov0TXNT9FsoFRQd7BJrP1tr%2B5KuWBzhjeiR%2BzLLryuaTkH72Akam7%2Fwu1uvr0cNqArqPv1el%2FTKWYKeAo0NYdw2%2F8BxVekcFQBAAA%3D&config=H4sIAAAAAAAAA02NSwrDMAxE76J1FiFLr7vNIYQtBwf%2FkBSoCb177aSl3QnNmzcn7GLBnFCRhXhc0rLiEwxoqySWQ1WYwJEtjFpYwCgf9JpAGbP4wmm0Im1o2%2BNL3dBfbSVFh4q%2FNvJG2mdIlnmZob9ScUekYRvTPbIlpZJ3ucKQg29gPEbp4iDrh758b3M%2FIFXIAAAA)

### Expected behavior

The metadata should be populated. In the attached example it should contain the class String.

### Actual behavior

The metadata is undefined

### Version

1.2.131

### Additional context

_No response_

Pull request description:
fix(es/proposal): Improve resolving of `design:returntype`
**Description:**

Emits `'design:returntype'` metadata when using `"decoratorMetadata": true`.

**Related issue:**

 - Closes #3319 

Patch:
diff --git a/bindings/Cargo.lock b/bindings/Cargo.lock
index 0820185fff..37c6ddb77f 100644
--- a/bindings/Cargo.lock
+++ b/bindings/Cargo.lock
@@ -230,7 +230,7 @@ dependencies = [
 
 [[package]]
 name = "binding_core_wasm"
-version = "1.3.98-nightly-20231118.1"
+version = "1.3.98-nightly-20231119.1"
 dependencies = [
  "anyhow",
  "getrandom",
@@ -290,7 +290,7 @@ dependencies = [
 
 [[package]]
 name = "binding_minifier_wasm"
-version = "1.3.98-nightly-20231118.1"
+version = "1.3.98-nightly-20231119.1"
 dependencies = [
  "anyhow",
  "getrandom",
@@ -2977,7 +2977,7 @@ dependencies = [
 
 [[package]]
 name = "swc_cli"
-version = "0.91.96"
+version = "0.91.97"
 dependencies = [
  "anyhow",
  "swc_cli_impl",
diff --git a/bindings/binding_core_wasm/Cargo.toml b/bindings/binding_core_wasm/Cargo.toml
index f3b329f35e..7f047c2a92 100644
--- a/bindings/binding_core_wasm/Cargo.toml
+++ b/bindings/binding_core_wasm/Cargo.toml
@@ -6,7 +6,7 @@ license     = "Apache-2.0"
 name        = "binding_core_wasm"
 publish     = false
 repository  = "https://github.com/swc-project/swc.git"
-version     = "1.3.98-nightly-20231118.1"
+version     = "1.3.98-nightly-20231119.1"
 
 [lib]
 bench      = false
diff --git a/bindings/binding_minifier_wasm/Cargo.toml b/bindings/binding_minifier_wasm/Cargo.toml
index e12c4cf966..7636d2b93c 100644
--- a/bindings/binding_minifier_wasm/Cargo.toml
+++ b/bindings/binding_minifier_wasm/Cargo.toml
@@ -6,7 +6,7 @@ license     = "Apache-2.0"
 name        = "binding_minifier_wasm"
 publish     = false
 repository  = "https://github.com/swc-project/swc.git"
-version     = "1.3.98-nightly-20231118.1"
+version     = "1.3.98-nightly-20231119.1"
 
 [lib]
 bench      = false
diff --git a/bindings/swc_cli/Cargo.toml b/bindings/swc_cli/Cargo.toml
index f94cc4fc45..4fd5142829 100644
--- a/bindings/swc_cli/Cargo.toml
+++ b/bindings/swc_cli/Cargo.toml
@@ -6,7 +6,7 @@ include     = ["Cargo.toml", "src/**/*.rs"]
 license     = "Apache-2.0"
 name        = "swc_cli"
 repository  = "https://github.com/swc-project/swc.git"
-version     = "0.91.96"
+version     = "0.91.97"
 
 [[bin]]
 bench = false
diff --git a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/metadata.rs b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/metadata.rs
index bbe5c6cc17..49f7f0abed 100644
--- a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/metadata.rs
+++ b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/metadata.rs
@@ -161,6 +161,19 @@ impl VisitMut for Metadata<'_> {
             );
             m.function.decorators.push(dec);
         }
+        {
+            // Copy tsc behaviour
+            // https://github.com/microsoft/TypeScript/blob/5e8c261b6ab746213f19ee3501eb8c48a6215dd7/src/compiler/transformers/typeSerializer.ts#L242
+            let dec = self.create_metadata_design_decorator(
+                "design:returntype",
+                if m.function.is_async {
+                    quote_ident!("Promise").as_arg()
+                } else {
+                    serialize_type(self.class_name, m.function.return_type.as_deref()).as_arg()
+                },
+            );
+            m.function.decorators.push(dec);
+        }
     }
 
     fn visit_mut_class_prop(&mut self, p: &mut ClassProp) {
diff --git a/package.json b/package.json
index 482f0f8cf3..7c6921aa71 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "@swc/core",
-    "version": "1.3.98-nightly-20231118.1",
+    "version": "1.3.98-nightly-20231119.1",
     "description": "Super-fast alternative for babel",
     "homepage": "https://swc.rs",
     "main": "./index.js",
diff --git a/packages/minifier/package.json b/packages/minifier/package.json
index f4758a8080..82b347f129 100644
--- a/packages/minifier/package.json
+++ b/packages/minifier/package.json
@@ -1,6 +1,6 @@
 {
     "name": "@swc/minifier",
-    "version": "1.3.98-nightly-20231118.1",
+    "version": "1.3.98-nightly-20231119.1",
     "description": "Super-fast alternative for terser",
     "homepage": "https://swc.rs",
     "main": "./index.js",


Test patch:
diff --git a/crates/swc/tests/fixture/issues-1xxx/1362/case1/output/index.ts b/crates/swc/tests/fixture/issues-1xxx/1362/case1/output/index.ts
index 33f7a93226..fcd6656c66 100644
--- a/crates/swc/tests/fixture/issues-1xxx/1362/case1/output/index.ts
+++ b/crates/swc/tests/fixture/issues-1xxx/1362/case1/output/index.ts
@@ -30,7 +30,8 @@ class AppController {
 _ts_decorate._([
     (0, _common.Get)(),
     _ts_metadata._("design:type", Function),
-    _ts_metadata._("design:paramtypes", [])
+    _ts_metadata._("design:paramtypes", []),
+    _ts_metadata._("design:returntype", Promise)
 ], AppController.prototype, "getHello", null);
 _ts_decorate._([
     (0, _common.Post)(),
@@ -38,7 +39,8 @@ _ts_decorate._([
     _ts_metadata._("design:type", Function),
     _ts_metadata._("design:paramtypes", [
         typeof _CreateUserDto.CreateUserDto === "undefined" ? Object : _CreateUserDto.CreateUserDto
-    ])
+    ]),
+    _ts_metadata._("design:returntype", Promise)
 ], AppController.prototype, "create", null);
 AppController = _ts_decorate._([
     (0, _common.Controller)(),
diff --git a/crates/swc/tests/fixture/issues-2xxx/2428/1/output/index.ts b/crates/swc/tests/fixture/issues-2xxx/2428/1/output/index.ts
index 38b959de44..da17886996 100644
--- a/crates/swc/tests/fixture/issues-2xxx/2428/1/output/index.ts
+++ b/crates/swc/tests/fixture/issues-2xxx/2428/1/output/index.ts
@@ -21,7 +21,8 @@ _ts_decorate._([
     _ts_metadata._("design:type", Function),
     _ts_metadata._("design:paramtypes", [
         Boolean
-    ])
+    ]),
+    _ts_metadata._("design:returntype", Promise)
 ], Foo.prototype, "fnName1", null);
 _ts_decorate._([
     _ts_param._(0, Arg("GraphQLArgName", {
@@ -30,5 +31,6 @@ _ts_decorate._([
     _ts_metadata._("design:type", Function),
     _ts_metadata._("design:paramtypes", [
         Boolean
-    ])
+    ]),
+    _ts_metadata._("design:returntype", Promise)
 ], Foo.prototype, "fnName2", null);
diff --git a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map
index 9a1093dd6a..809e15a57c 100644
--- a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map
+++ b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.map
@@ -1,5 +1,5 @@
 {
-  "mappings": ";;;AAAA,SAASA,IAAI,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,eAAe,QAAQ,iBAAiB;AAElG,SACIC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,QACpB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,OAAO,QAAQ,wCAAwC;AAChE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,gBAAgB,QAAQ,uCAAuC;AAIxE,OAAO,MAAMC;IACTC,YAAY,AAAQC,cAA8B,CAAE;aAAhCA,iBAAAA;IAAkC;IAI/CC,cACH,AAAaC,EAAU,EACvB,AAAQC,gBAAkC,EAC1C,AAAQC,IAAc,EACxB;QACE,OAAO,IAAI,CAACJ,cAAc,CAACK,MAAM,CAACH,IAAIC,kBAAkBC,KAAKF,EAAE;IACnE;IAIOI,cAAc,AAAaJ,EAAU,EAAE,AAAQE,IAAc,EAAE;QAClE,OAAO,IAAI,CAACJ,cAAc,CAACO,MAAM,CAACL,IAAIE,KAAKF,EAAE;IACjD;AACJ;;IAfKhB,UAAUQ;IACVT,IAAIK;IAEAN,aAAAA,MAAM;IACNH,aAAAA;IACAc,aAAAA;;;;eADyB,4CAAA;eACZ,oCAAA;;GARTG;;IAaRZ,UAAUQ;IACVX,OAAOM;IACcL,aAAAA,MA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body",
     "Controller",
diff --git a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.ts b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.ts
index 6265f3205f..a1debc70bb 100644
--- a/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.ts
+++ b/crates/swc/tests/fixture/sourcemap/011/output/CommentControlller.ts
@@ -32,7 +32,8 @@ _ts_decorate([
         String,
         typeof UpdateCommentDto === "undefined" ? Object : UpdateCommentDto,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], CommentController.prototype, "updateComment", null);
 _ts_decorate([
     UseGuards(JwtAuthGuard),
@@ -43,7 +44,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         String,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], CommentController.prototype, "deleteComment", null);
 CommentController = _ts_decorate([
     Controller(COMMENT_CONTROLLER_ROUTE),
diff --git a/crates/swc/tests/fixture/sourcemap/013/output/PistController.map b/crates/swc/tests/fixture/sourcemap/013/output/PistController.map
index 3f9abb4d22..14f26a1d47 100644
--- a/crates/swc/tests/fixture/sourcemap/013/output/PistController.map
+++ b/crates/swc/tests/fixture/sourcemap/013/output/PistController.map
@@ -1,5 +1,5 @@
 {
-  "mappings": ";;;AAAA,SACIA,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,qBAAqB,EACrBC,iBAAiB,EACjBC,4BAA4B,EAC5BC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASX,QAAQY,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,aAAa,QAAQ,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ACZ,oCAAA;;;GAzCTK;AAAAA;IAFZzB,WAAWQ;IACXD,gBAAgBQ,mCAAmCC;;;eAEf,uCAAA;eAAqC,0CAAA;;GAD7DS",
   "names": [
     "Body",
     "Controller",
diff --git a/crates/swc/tests/fixture/sourcemap/013/output/PistController.ts b/crates/swc/tests/fixture/sourcemap/013/output/PistController.ts
index 5d568eca90..7f7ef74be7 100644
--- a/crates/swc/tests/fixture/sourcemap/013/output/PistController.ts
+++ b/crates/swc/tests/fixture/sourcemap/013/output/PistController.ts
@@ -40,7 +40,8 @@ export class PostController {
 _ts_decorate([
     Get(POST_GET_ALL_ENDPOINT),
     _ts_metadata("design:type", Function),
-    _ts_metadata("design:paramtypes", [])
+    _ts_metadata("design:paramtypes", []),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "getPosts", null);
 _ts_decorate([
     Get(POST_GET_ENDPOINT),
@@ -48,7 +49,8 @@ _ts_decorate([
     _ts_metadata("design:type", Function),
     _ts_metadata("design:paramtypes", [
         String
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "getPost", null);
 _ts_decorate([
     UseGuards(JwtAuthGuard),
@@ -59,7 +61,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         typeof CreatePostDto === "undefined" ? Object : CreatePostDto,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "createPost", null);
 _ts_decorate([
     UseGuards(JwtAuthGuard),
@@ -72,7 +75,8 @@ _ts_decorate([
         String,
         typeof CreatePostDto === "undefined" ? Object : CreatePostDto,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "updatePost", null);
 _ts_decorate([
     UseGuards(JwtAuthGuard),
@@ -83,7 +87,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         String,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "deletePost", null);
 _ts_decorate([
     UseInterceptors(MongooseClassSerializerInterceptor(Comment)),
@@ -97,7 +102,8 @@ _ts_decorate([
         String,
         typeof CreateCommentDto === "undefined" ? Object : CreateCommentDto,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], PostController.prototype, "createPostComment", null);
 PostController = _ts_decorate([
     Controller(POST_CONTROLLER_ROUTE),
diff --git a/crates/swc/tests/fixture/sourcemap/014/output/UserController.map b/crates/swc/tests/fixture/sourcemap/014/output/UserController.map
index 0978f785f8..835902b088 100644
--- a/crates/swc/tests/fixture/sourcemap/014/output/UserController.map
+++ b/crates/swc/tests/fixture/sourcemap/014/output/UserController.map
@@ -1,5 +1,5 @@
 {
-  "mappings": ";;;AAAA,SACIA,UAAU,EACVC,IAAI,EACJC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,kBAAkB,EAClBC,eAAe,QACZ,iBAAiB;AAExB,SACIC,qBAAqB,EACrBC,oBAAoB,EACpBC,oBAAoB,QACjB,gCAAgC;AACvC,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,IAAI,QAAQ,mCAAmC;AACxD,SAASA,QAAQC,QAAQ,QAAQ,kCAAkC;AACnE,SAASC,kCAAkC,QAAQ,0DAA0D;AAC7G,SAASC,WAAW,QAAQ,2BAA2B;AAIvD,OAAO,MAAMC;IACTC,YAAY,AAAQC,WAAwB,CAAE;aAA1BA,cAAAA;IAA4B;IAEhD,MACMC,OAAO,AAAQC,aAA4B,EAAE;QAC/C,OAAO,IAAI,CAACF,WAAW,CAACG,MAAM,CAACD;IACnC;IAEA,MAEME,OACF,AAAaC,MAAc,EAC3B,AAAQC,aAA4B,EACpC,AAAQC,IAAc,EACxB;QACE,IAAIA,KAAKC,EAAE,KAAKH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GAJ3Be;;IAQRhB,UAAUW;IACVT,IAAIM;IAEAL,aAAAA,MAAM;IACNF,aAAAA;IACAW,aAAAA;;;;eADsB,yCAAA;eACT,oCAAA;;;GAbTI;AAAAA;IAFZlB,WAAWQ;IACXD,gBAAgBS,mCAAmCD;;;eAEf,uCAAA;;GADxBG",
   "names": [
     "Controller",
     "Post",
diff --git a/crates/swc/tests/fixture/sourcemap/014/output/UserController.ts b/crates/swc/tests/fixture/sourcemap/014/output/UserController.ts
index 822382561f..ae52a03e9a 100644
--- a/crates/swc/tests/fixture/sourcemap/014/output/UserController.ts
+++ b/crates/swc/tests/fixture/sourcemap/014/output/UserController.ts
@@ -30,7 +30,8 @@ _ts_decorate([
     _ts_metadata("design:type", Function),
     _ts_metadata("design:paramtypes", [
         typeof CreateUserDto === "undefined" ? Object : CreateUserDto
-    ])
+    ]),
+    _ts_metadata("design:returntype", Promise)
 ], UserController.prototype, "signup", null);
 _ts_decorate([
     UseGuards(JwtAuthGuard),
@@ -43,7 +44,8 @@ _ts_decorate([
         String,
         typeof UpdateUserDto === "undefined" ? Object : UpdateUserDto,
         typeof UserType === "undefined" ? Object : UserType
-    ])
+    ]),
+    _ts_metadata("design:returntype", Promise)
 ], UserController.prototype, "update", null);
 UserController = _ts_decorate([
     Controller(USER_CONTROLLER_ROUTE),
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/input.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/input.ts
new file mode 100644
index 0000000000..caa7e1e138
--- /dev/null
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/input.ts
@@ -0,0 +1,34 @@
+import 'reflect-metadata'
+
+let returnType: unknown;
+
+function decorator(target: any, key: string | symbol, descriptor: PropertyDescriptor): void {
+    returnType = Reflect.getMetadata('design:returntype', target, key);
+}
+
+class Foo {
+    @decorator
+    public foo(x: string): string {
+        return 'foo';
+    }
+
+    @decorator
+    public bar(x: string): number {
+        return 123;
+    }
+
+    @decorator
+    public baz(): string | number {
+        return 'baz';
+    }
+
+    @decorator
+    public qux() {
+        return 'qux';
+    }
+
+    @decorator
+    public async quux() {
+        return 'quux';
+    }
+}
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/output.ts
new file mode 100644
index 0000000000..798e718c55
--- /dev/null
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/issues/3319/output.ts
@@ -0,0 +1,55 @@
+import 'reflect-metadata';
+
+let returnType: unknown;
+
+function decorator(target: any, key: string | symbol, descriptor: PropertyDescriptor): void {
+    returnType = Reflect.getMetadata('design:returntype', target, key);
+}
+
+class Foo {
+    public foo(x: string): string {
+        return 'foo';
+    }
+    public bar(x: string): number {
+        return 123;
+    }
+    public baz(): string | number {
+        return 'baz';
+    }
+    public qux() {
+        return 'qux';
+    }
+    public async quux() {
+        return 'quux';
+    }
+}
+_ts_decorate([
+    decorator,
+    _ts_metadata("design:type", Function),
+    _ts_metadata("design:paramtypes", [String]),
+    _ts_metadata("design:returntype", String)
+], Foo.prototype, "foo", null);
+_ts_decorate([
+    decorator,
+    _ts_metadata("design:type", Function),
+    _ts_metadata("design:paramtypes", [String]),
+    _ts_metadata("design:returntype", Number)
+], Foo.prototype, "bar", null);
+_ts_decorate([
+    decorator,
+    _ts_metadata("design:type", Function),
+    _ts_metadata("design:paramtypes", []),
+    _ts_metadata("design:returntype", Object)
+], Foo.prototype, "baz", null);
+_ts_decorate([
+    decorator,
+    _ts_metadata("design:type", Function),
+    _ts_metadata("design:paramtypes", []),
+    _ts_metadata("design:returntype", void 0)
+], Foo.prototype, "qux", null);
+_ts_decorate([
+    decorator,
+    _ts_metadata("design:type", Function),
+    _ts_metadata("design:paramtypes", []),
+    _ts_metadata("design:returntype", Promise)
+], Foo.prototype, "quux", null);
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/generics/base/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/generics/base/output.ts
index 9fabc534d7..ad4877a206 100644
--- a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/generics/base/output.ts
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/generics/base/output.ts
@@ -9,7 +9,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         typeof Inter === "undefined" ? Object : Inter,
         typeof InterGen === "undefined" ? Object : InterGen
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], MyClass.prototype, "method", null);
 MyClass = _ts_decorate([
     Decorate,
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/nest/injection/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/nest/injection/output.ts
index f509e9ae54..58898af20c 100644
--- a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/nest/injection/output.ts
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/nest/injection/output.ts
@@ -27,7 +27,8 @@ _ts_decorate([
 _ts_decorate([
     Get(),
     _ts_metadata("design:type", Function),
-    _ts_metadata("design:paramtypes", [])
+    _ts_metadata("design:paramtypes", []),
+    _ts_metadata("design:returntype", String)
 ], AppController.prototype, "getHello", null);
 _ts_decorate([
     Get("/callback"),
@@ -37,7 +38,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         typeof express === "undefined" || typeof express.Response === "undefined" ? Object : express.Response,
         typeof express === "undefined" || typeof express.Express === "undefined" || typeof express.Express.Session === "undefined" ? Object : express.Express.Session
-    ])
+    ]),
+    _ts_metadata("design:returntype", Promise)
 ], AppController.prototype, "callback", null);
 AppController = _ts_decorate([
     Controller(),
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/paramters/decorated-types/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/paramters/decorated-types/output.ts
index c09c39f005..32ec3b6ae2 100644
--- a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/paramters/decorated-types/output.ts
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/paramters/decorated-types/output.ts
@@ -21,7 +21,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         String,
         void 0
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], MyOtherClass.prototype, "methodUndecorated", null);
 _ts_decorate([
     decorate("named"),
@@ -31,7 +32,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         typeof Injected === "undefined" ? Object : Injected,
         typeof Schema === "undefined" ? Object : Schema
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], MyOtherClass.prototype, "method", null);
 MyOtherClass = _ts_decorate([
     _ts_param(0, inject()),
@@ -52,7 +54,8 @@ _ts_decorate([
     _ts_metadata("design:type", Function),
     _ts_metadata("design:paramtypes", [
         String
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], DecoratedClass.prototype, "method", null);
 DecoratedClass = _ts_decorate([
     Decorate,
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/type/serialization/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/type/serialization/output.ts
index 93b782cd42..4691fb76c5 100644
--- a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/type/serialization/output.ts
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/metadata/type/serialization/output.ts
@@ -34,7 +34,8 @@ _ts_decorate([
         typeof Object === "undefined" ? Object : Object,
         Object,
         typeof BigInt === "undefined" ? Object : BigInt
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], Sample.prototype, "method", null);
 _ts_decorate([
     Decorate(),
@@ -42,14 +43,16 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         typeof Decorate === "undefined" || typeof Decorate.Name === "undefined" ? Object : Decorate.Name,
         typeof Decorate === "undefined" || typeof Decorate.Name === "undefined" ? Object : Decorate.Name
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], Sample.prototype, "method2", null);
 _ts_decorate([
     Decorate(),
     _ts_metadata("design:type", Function),
     _ts_metadata("design:paramtypes", [
         String
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], Sample.prototype, "assignments", null);
 Sample = _ts_decorate([
     Decorate(),
diff --git a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/method/param/output.ts b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/method/param/output.ts
index 59505dacc7..e392c56426 100644
--- a/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/method/param/output.ts
+++ b/crates/swc_ecma_transforms/tests/fixture/legacy-metadata/method/param/output.ts
@@ -9,7 +9,8 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         String,
         String
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], Foo.prototype, "foo", null);
 _ts_decorate([
     _ts_param(0, dec1()),
@@ -18,5 +19,6 @@ _ts_decorate([
     _ts_metadata("design:paramtypes", [
         String,
         String
-    ])
+    ]),
+    _ts_metadata("design:returntype", void 0)
 ], Foo, "bar", null);