Skip to content

Trailing comments of ClassMethod are reported as trailing comments of BlockStatement when the method has no code inside but has a comment #11469

@ShukantPal

Description

@ShukantPal

Starting from this code:

class ExampleAST {
  /** @ctor */
  constructor() {
    /** @member */
    this.member = 'value';
  }

  /* Trailing comment */
}

The /* Trailing comment */ is in the trailingComments of the ClassMethod "constructor". However, if you comment out the only line of code in the constructor:

class ExampleAST {
  /** @ctor */
  constructor() {
    /** @member */
    // this.member = 'value';
  }

  /* Trailing comment */
}

Then, the trailing comment appears in the trailing comments of the BlockStatement inside the constructor.

Furthermore, if you remove both comments from inside the constructor, then the trailing comments work as expected (trailing comments of the ClassMethod, not BlockStatement).

https://astexplorer.net/#/gist/3d8ffdbbe3c3f2929911f50419821e6e/1f6b623281bdc6a0b320aa1e115edcdca483dfe7

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commentsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions