Skip to content

Commit 4949f15

Browse files
authored
Correctly print leading block comments for class methods (#6168)
1 parent cb9b82e commit 4949f15

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

packages/shared/babel-ast-utils/src/generator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ for (let key in generator) {
274274
// These are printed by astring itself
275275
if (node.trailingComments) {
276276
for (let c of node.trailingComments) {
277-
if (c.type === 'CommentLine') {
277+
if (c.type === 'CommentLine' || c.type === 'LineComment') {
278278
c.type = 'LineComment';
279279
} else {
280280
c.type = 'BlockComment';

packages/shared/babel-ast-utils/test/fixtures/class.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class C extends A {
77
get property() {
88
return this._property;
99
}
10+
// /* foo */
1011
set property(value) {
1112
this._property = value;
1213
}

0 commit comments

Comments
 (0)