File tree 4 files changed +78
-0
lines changed
swc/tests/fixture/issues-4xxx/4311
4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "jsc" : {
3
+ "parser" : {
4
+ "syntax" : " typescript" ,
5
+ "decorators" : true ,
6
+ "tsx" : false ,
7
+ "keepClassNames" : true
8
+ },
9
+ "target" : " es2020" ,
10
+ "preserveAllComments" : true ,
11
+ "loose" : false ,
12
+ "minify" : {
13
+ "compress" : false ,
14
+ "mangle" : false
15
+ }
16
+ },
17
+ "module" : {
18
+ "type" : " commonjs"
19
+ },
20
+ "minify" : false ,
21
+ "isModule" : true
22
+ }
Original file line number Diff line number Diff line change
1
+ const printMemberName = ( target : any , memberName : string ) => {
2
+ console . log ( memberName ) ;
3
+ } ;
4
+
5
+ class TestClass {
6
+
7
+
8
+ // moving the decorator below the comment works as expected
9
+
10
+ @printMemberName
11
+ /**
12
+ * some tsdoc comments
13
+ *
14
+ * Some more comments
15
+ * over
16
+ * multiple
17
+ * lines
18
+ */
19
+ async run ( ) : Promise < boolean > {
20
+ return await Promise . resolve ( true ) ;
21
+ }
22
+ }
23
+
24
+ export { TestClass } ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ Object . defineProperty ( exports , "__esModule" , {
3
+ value : true
4
+ } ) ;
5
+ Object . defineProperty ( exports , "TestClass" , {
6
+ enumerable : true ,
7
+ get : function ( ) {
8
+ return TestClass ;
9
+ }
10
+ } ) ;
11
+ const _ts_decorate = require ( "@swc/helpers/_/_ts_decorate" ) ;
12
+ const printMemberName = ( target , memberName ) => {
13
+ console . log ( memberName ) ;
14
+ } ;
15
+ class TestClass {
16
+ // moving the decorator below the comment works as expected
17
+ /**
18
+ * some tsdoc comments
19
+ *
20
+ * Some more comments
21
+ * over
22
+ * multiple
23
+ * lines
24
+ */ async run ( ) {
25
+ return await Promise . resolve ( true ) ;
26
+ }
27
+ }
28
+ _ts_decorate . _ ( [
29
+ printMemberName
30
+ ] , TestClass . prototype , "run" , null ) ;
Original file line number Diff line number Diff line change @@ -1474,6 +1474,8 @@ where
1474
1474
fn emit_class_method ( & mut self , n : & ClassMethod ) -> Result {
1475
1475
self . emit_leading_comments_of_span ( n. span ( ) , false ) ?;
1476
1476
1477
+ self . emit_leading_comments_of_span ( n. key . span ( ) , false ) ?;
1478
+
1477
1479
srcmap ! ( n, true ) ;
1478
1480
1479
1481
for d in & n. function . decorators {
You can’t perform that action at this time.
0 commit comments