mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
fix(es/codegen): Fix codegen of async methods with decorators (#8575)
**Related issue:** - Closes #4311
This commit is contained in:
parent
d006482bd9
commit
8c322250b7
22
crates/swc/tests/fixture/issues-4xxx/4311/input/.swcrc
Normal file
22
crates/swc/tests/fixture/issues-4xxx/4311/input/.swcrc
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"decorators": true,
|
||||
"tsx": false,
|
||||
"keepClassNames": true
|
||||
},
|
||||
"target": "es2020",
|
||||
"preserveAllComments": true,
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
},
|
||||
"minify": false,
|
||||
"isModule": true
|
||||
}
|
24
crates/swc/tests/fixture/issues-4xxx/4311/input/1.js
Normal file
24
crates/swc/tests/fixture/issues-4xxx/4311/input/1.js
Normal file
@ -0,0 +1,24 @@
|
||||
const printMemberName = (target: any, memberName: string) => {
|
||||
console.log(memberName);
|
||||
};
|
||||
|
||||
class TestClass {
|
||||
|
||||
|
||||
// moving the decorator below the comment works as expected
|
||||
|
||||
@printMemberName
|
||||
/**
|
||||
* some tsdoc comments
|
||||
*
|
||||
* Some more comments
|
||||
* over
|
||||
* multiple
|
||||
* lines
|
||||
*/
|
||||
async run(): Promise<boolean> {
|
||||
return await Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
export { TestClass };
|
30
crates/swc/tests/fixture/issues-4xxx/4311/output/1.js
Normal file
30
crates/swc/tests/fixture/issues-4xxx/4311/output/1.js
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "TestClass", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return TestClass;
|
||||
}
|
||||
});
|
||||
const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
|
||||
const printMemberName = (target, memberName)=>{
|
||||
console.log(memberName);
|
||||
};
|
||||
class TestClass {
|
||||
// moving the decorator below the comment works as expected
|
||||
/**
|
||||
* some tsdoc comments
|
||||
*
|
||||
* Some more comments
|
||||
* over
|
||||
* multiple
|
||||
* lines
|
||||
*/ async run() {
|
||||
return await Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
_ts_decorate._([
|
||||
printMemberName
|
||||
], TestClass.prototype, "run", null);
|
@ -1474,6 +1474,8 @@ where
|
||||
fn emit_class_method(&mut self, n: &ClassMethod) -> Result {
|
||||
self.emit_leading_comments_of_span(n.span(), false)?;
|
||||
|
||||
self.emit_leading_comments_of_span(n.key.span(), false)?;
|
||||
|
||||
srcmap!(n, true);
|
||||
|
||||
for d in &n.function.decorators {
|
||||
|
Loading…
Reference in New Issue
Block a user