Skip to content

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

@ziadkh0

Description

@ziadkh0

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();
        }
      },
      //...
    },
  };

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commentsarea: flowoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions