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 6deee84
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 992 deletions.
16 changes: 7 additions & 9 deletions packages/babel-generator/src/printer.ts
Expand Up @@ -3,7 +3,6 @@ import type { Loc } from "./buffer";
import * as n from "./node";
import type * as t from "@babel/types";
import {
isProperty,
isFunction,
isStatement,
isClassBody,
Expand Down Expand Up @@ -1018,20 +1017,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 6deee84

Please sign in to comment.