Skip to content

Nestled JSDoc comments are still broken after #9672 #12653

@thw0rted

Description

@thw0rted

Prettier 2.6.2
Playground link

--parser babel

Input:

const foo = "Bar";

/**
 * @template T
 * @param {Type} type
 * @param {T} value
 * @return {Value}
 *//**
 * @param {Type} type
 * @return {Value}
 */
function value(type, value) {
  if (arguments.length === 2) {
    return new ConcreteValue(type, value);
  } else {
    return new Value(type);
  }
}

Output:

const foo = "Bar";

/**
 * @template T
 * @param {Type} type
 * @param {T} value
 * @return {Value}
 */ /**
 * @param {Type} type
 * @return {Value}
 */
function value(type, value) {
  if (arguments.length === 2) {
    return new ConcreteValue(type, value);
  } else {
    return new Value(type);
  }
}

Expected behavior:

As reported in #7724, JSDoc function overloads require two comment blocks "nestled" together. When that issue was reported, "nestled" comments would have a blank line inserted between them, breaking the JSDoc parser. That issue was closed via #9672. Now, instead of inserting a blank line, Prettier inserts a single space, turning *//** into */ /**. This still breaks the JSDoc parser. The sequence must be exactly *//**, and it must not be modified by Prettier at all.

/cc @fisker, who wrote the linked PR, and @grassator who reported the previous issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JS

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions