Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
pyramation opened this issue Oct 11, 2022 · 5 comments 路 Fixed by #15037 or #15216
Closed
1 task

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

pyramation opened this issue Oct 11, 2022 · 5 comments 路 Fixed by #15037 or #15216
Assignees
Labels
area: comments i: enhancement i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator

Comments

@pyramation
Copy link

馃捇

  • 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

@babel-bot
Copy link
Collaborator

Hey @pyramation! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@liuxingbaoyu liuxingbaoyu self-assigned this Oct 11, 2022
@pyramation pyramation changed the title [Bug]: whitespace issue introduced after new PR [Bug]: whitespace issue with CommentBlock introduced after new PR Oct 11, 2022
@pyramation
Copy link
Author

https://github.com/pyramation/babel-issue-15036

the breaking commit is when I upgrade babel: pyramation/babel-issue-15036@e298022

You can see leading comments lose their trailing newlines

@pyramation
Copy link
Author

I've found a new one that is technically the same issue, but should we reopen this or make a new one?

this

/** This describes how the endpoint is implemented when the lease is deployed */
export enum Endpoint_Kind {
  /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */
  SHARED_HTTP = 0,
  /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */
  RANDOM_PORT = 1,
  UNRECOGNIZED = -1,
}

becomes

/** This describes how the endpoint is implemented when the lease is deployed */
export enum Endpoint_Kind {
  /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */SHARED_HTTP = 0,
  /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */RANDOM_PORT = 1,
  UNRECOGNIZED = -1,
}

@liuxingbaoyu
Copy link
Member

Either way looks fine to me.

@liuxingbaoyu liuxingbaoyu reopened this Nov 23, 2022
@pyramation
Copy link
Author

Thanks! I think re-open makes sense ;)

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: comments i: enhancement i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator
Projects
None yet
3 participants