Repository: prettier/prettier
File: src/language-js/parse/postprocess/index.js (JavaScript)

Code before:
            name: node.name,
            range: [start, start + node.name.length],
          };
        }
        break;

      // For hack-style pipeline
      case "TopicReference":
        ast.extra = { ...ast.extra, __isUsingHackPipeline: true };
        break;

      // In Flow parser, it doesn't generate union/intersection types for single type
      case "TSUnionType":
      case "TSIntersectionType":
        if (node.types.length === 1) {
          return node.types[0];
        }
        break;
    }
  });

  if (isNonEmptyArray(ast.comments)) {
    let followingComment;
    for (let i = ast.comments.length - 1; i >= 0; i--) {
      const comment = ast.comments[i];
      assertComment(comment, text);

      if (
        followingComment &&
        locEnd(comment) === locStart(followingComment) &&
        isBlockComment(comment) &&
        isBlockComment(followingComment) &&
        isIndentableBlockComment(comment) &&
        isIndentableBlockComment(followingComment)
      ) {
        ast.comments.splice(i + 1, 1);
        comment.value += "*//*" + followingComment.value;
        comment.range = [locStart(comment), locEnd(followingComment)];

        assertComment(comment, text);
      }

      followingComment = comment;
    }
  }

  // In `typescript`/`espree`/`flow`, `Program` doesn't count whitespace and comments
  // See https://github.com/eslint/espree/issues/488
  if (ast.type === "Program") {
    ast.range = [0, text.length];
  }

Review comment (suggestion):
I think assertions for production environments should be considered separately from assertions for development environments.
Therefore, I propose to add a simple validation like the one below and remove the relevant part from `assertComment` and wrap `assertComment` call in `if (process.env.NODE_ENV !== "production")`:

```js
if (!isLineComment(comment) && !isBlockComment(comment)) {
    throw new TypeError(`Unknown comment type: "${comment.type}".`);
}
```

Code after:
            name: node.name,
            range: [start, start + node.name.length],
          };
        }
        break;

      // For hack-style pipeline
      case "TopicReference":
        ast.extra = { ...ast.extra, __isUsingHackPipeline: true };
        break;

      // In Flow parser, it doesn't generate union/intersection types for single type
      case "TSUnionType":
      case "TSIntersectionType":
        if (node.types.length === 1) {
          return node.types[0];
        }
        break;
    }
  });

  if (isNonEmptyArray(ast.comments)) {
    let followingComment;
    for (let i = ast.comments.length - 1; i >= 0; i--) {
      const comment = ast.comments[i];

      if (
        followingComment &&
        locEnd(comment) === locStart(followingComment) &&
        isBlockComment(comment) &&
        isBlockComment(followingComment) &&
        isIndentableBlockComment(comment) &&
        isIndentableBlockComment(followingComment)
      ) {
        ast.comments.splice(i + 1, 1);
        comment.value += "*//*" + followingComment.value;
        comment.range = [locStart(comment), locEnd(followingComment)];
      }

      if (!isLineComment(comment) && !isBlockComment(comment)) {
        throw new TypeError(`Unknown comment type: "${comment.type}".`);
      }

      /* c8 ignore next 3 */
      if (process.env.NODE_ENV !== "production") {
        assertComment(comment, text);
      }

      followingComment = comment;
    }
  }