Skip to content

Flow comments plugin moves the generic type arguments of the left hand side of the extends keyword to its right side #10323

@ziadkh0

Description

@ziadkh0

Bug Report

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

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

Input Code
REPL link

class A<X> extends B {}

Expected behavior/code

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

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.typeParameters) {
          const typeParameters = path.get("typeParameters");
          const id = path.get("id");
          id.addComment("trailing", generateComment(typeParameters, node));
          typeParameters.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