Skip to content

[Bug]: whitespace issue with CommentBlock introduced after new PR #15036

@pyramation

Description

@pyramation

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

generate code from this AST in the lastest version after this PR: #14979

{
  "type": "File",
  "errors": [],
  "program": {
    "type": "Program",
    "sourceType": "module",
    "interpreter": null,
    "body": [
      {
        "type": "ExportNamedDeclaration",
        "exportKind": "type",
        "specifiers": [],
        "source": null,
        "declaration": {
          "type": "TSInterfaceDeclaration",
          "id": {
            "type": "Identifier",
            "name": "CPU"
          },
          "body": {
            "type": "TSInterfaceBody",
            "body": [
              {
                "type": "TSPropertySignature",
                "key": {
                  "type": "Identifier",
                  "name": "units"
                },
                "computed": false,
                "typeAnnotation": {
                  "type": "TSTypeAnnotation",
                  "typeAnnotation": {
                    "type": "TSTypeReference",
                    "typeName": {
                      "type": "Identifier",
                      "name": "ResourceValue"
                    }
                  }
                }
              },
              {
                "type": "TSPropertySignature",
                "key": {
                  "type": "Identifier",
                  "name": "attributes"
                },
                "computed": false,
                "typeAnnotation": {
                  "type": "TSTypeAnnotation",
                  "typeAnnotation": {
                    "type": "TSArrayType",
                    "elementType": {
                      "type": "TSTypeReference",
                      "typeName": {
                        "type": "Identifier",
                        "name": "Attribute"
                      }
                    }
                  }
                }
              }
            ]
          }
        },
        "leadingComments": [
          {
            "type": "CommentBlock",
            "value": "* CPU stores resource units and cpu config attributes "
          }
        ]
      }
    ],
    "directives": []
  },
  "comments": [
    {
      "type": "CommentBlock",
      "value": "* CPU stores resource units and cpu config attributes "
    }
  ]
}

Configuration file name

No response

Configuration

No response

Current and expected behavior

expected

/** CPU stores resource units and cpu config attributes */
export interface CPU {
    units: ResourceValue;
    attributes: Attribute[];
}

current after PR

/** CPU stores resource units and cpu config attributes */export interface CPU {
    units: ResourceValue;
    attributes: Attribute[];
}

diff

-/** CPU stores resource units and cpu config attributes */
-export interface CPU {
+/** CPU stores resource units and cpu config attributes */export interface CPU {
   units: ResourceValue;
   attributes: Attribute[];
 }

Environment

System:
OS: macOS 12.2
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.18.0 - /usr/local/bin/yarn
npm: 8.3.1 - /usr/local/bin/npm
Monorepos:
Yarn Workspaces: 1.18.0
Lerna: 4.0.0
npmPackages:
@babel/cli: 7.19.3 => 7.19.3
@babel/core: 7.19.3 => 7.19.3
@babel/eslint-parser: ^7.19.1 => 7.19.1
babel-core: 7.0.0-bridge.0 => 7.0.0-bridge.0
babel-jest: ^29.1.2 => 29.1.2
eslint: 8.25.0 => 8.25.0
jest: 29.1.2 => 29.1.2
lerna: 4.0.0 => 4.0.0

Possible solution

No response

Additional context

#14979

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions