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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow comments plugin removes generic type arguments of the right hand side of the `extends` keyword #10321

Closed
zaygraveyard opened this issue Aug 12, 2019 · 3 comments

Comments

@zaygraveyard
Copy link
Contributor

commented Aug 12, 2019

Bug Report

Current Behavior
@babel/plugin-transform-flow-comments removes generic type arguments of the right hand side of the extends keyword

class A extends B {}

Input Code
REPL link

class A extends B<X> {}

Expected behavior/code

class A extends B /*:: <X>*/ {}

Environment

  • Babel version(s): v7.5.5
  • How you are using Babel: Online REPL

Possible Solution

  return {
    //...
    visitor: {
      //...
      ClassDeclaration(path) {
        if (path.parentPath.isFlow()) {
          return;
        }

        const { node } = path;
        if (node.superTypeParameters) {
          const superTypeParameters = path.get("superTypeParameters");
          const superClass = path.get("superClass");
          superClass.addComment("trailing", generateComment(superTypeParameters, node));
          superTypeParameters.remove();
        }
      },
      //...
    },
  };
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Aug 12, 2019

Hey @zaygraveyard! 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.

@JLHwung

This comment has been minimized.

Copy link
Contributor

commented Aug 12, 2019

PR is welcome.

@zaygraveyard

This comment has been minimized.

Copy link
Contributor Author

commented Aug 13, 2019

I'm working on a PR

nicolo-ribaudo added a commit that referenced this issue Aug 14, 2019

Fix flow comments plugin issues (#10329)
* Fix issues in flow-comments to preserve comments and there order (fixes #10324)

* Add support in flow-comments for extends in class declarations (fixes #10323, #10321)

* Refactoring and cleanup of flow-comments plugin

* Fix comments preservation logic of flow-comments

* Fix flow-comments where comments are class identifier and extends keyword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.