Skip to content

Commit

Permalink
fix and babel8
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Oct 12, 2022
1 parent 0cf343d commit b9222b4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 991 deletions.
15 changes: 7 additions & 8 deletions packages/babel-generator/src/printer.ts
Expand Up @@ -1018,20 +1018,19 @@ class Printer {
hasLoc = false;

if (len === 1) {
const shouldSkipNewline =
!isStatement(node) &&
!isClassBody(parent) &&
!isTSInterfaceBody(parent);

if (type === COMMENT_TYPE.LEADING) {
this._printComment(
comment,
(!isStatement(node) && !isProperty(node)) ||
isFunction(parent, { body: node })
shouldSkipNewline || isFunction(parent, { body: node })
? COMMENT_SKIP_NEWLINE.SKIP_ALL
: COMMENT_SKIP_NEWLINE.DEFAULT,
);
} else if (
type === COMMENT_TYPE.TRAILING &&
!isStatement(node) &&
!isClassBody(parent) &&
!isTSInterfaceBody(parent)
) {
} else if (type === COMMENT_TYPE.TRAILING && shouldSkipNewline) {
this._printComment(comment, COMMENT_SKIP_NEWLINE.SKIP_ALL);
} else {
this._printComment(comment, COMMENT_SKIP_NEWLINE.DEFAULT);
Expand Down

0 comments on commit b9222b4

Please sign in to comment.