Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Oct 12, 2022
1 parent c54417e commit 3bcf3b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 13 additions & 2 deletions packages/babel-generator/src/printer.ts
Expand Up @@ -2,7 +2,13 @@ import Buffer from "./buffer";
import type { Loc } from "./buffer";
import * as n from "./node";
import type * as t from "@babel/types";
import { isProperty, isFunction, isStatement, isLVal } from "@babel/types";
import {
isProperty,
isFunction,
isStatement,
isClassBody,
isTSInterfaceBody,
} from "@babel/types";
import type {
RecordAndTuplePluginOptions,
PipelineOperatorPluginOptions,
Expand Down Expand Up @@ -1020,7 +1026,12 @@ class Printer {
? COMMENT_SKIP_NEWLINE.SKIP_ALL
: COMMENT_SKIP_NEWLINE.DEFAULT,
);
} else if (type === COMMENT_TYPE.TRAILING && isLVal(node)) {
} else if (
type === COMMENT_TYPE.TRAILING &&
!isStatement(node) &&
!isClassBody(parent) &&
!isTSInterfaceBody(parent)
) {
this._printComment(comment, COMMENT_SKIP_NEWLINE.SKIP_ALL);
} else {
this._printComment(comment, COMMENT_SKIP_NEWLINE.DEFAULT);
Expand Down
@@ -1,4 +1,2 @@
var a = (y /*: any*/);
var a = ((y /*: foo*/)
/*: any*/
);
var a = ((y /*: foo*/) /*: any*/);

0 comments on commit 3bcf3b0

Please sign in to comment.