src/language-js/comments.js/willPrintOwnComments
function willPrintOwnComments(path /*, options */) {
  const node = path.getValue();
  const parent = path.getParentNode();

  const hasFlowAnnotations = (node) =>
    hasFlowAnnotationComment(getComments(node, CommentCheckFlags.Leading)) ||
    hasFlowAnnotationComment(getComments(node, CommentCheckFlags.Trailing));

  return (
    ((node &&
      (isJsxNode(node) ||
        hasFlowShorthandAnnotationComment(node) ||
        (isCallExpression(parent) && hasFlowAnnotations(node)))) ||
      (parent &&
        (parent.type === "JSXSpreadAttribute" ||
          parent.type === "JSXSpreadChild" ||
          parent.type === "UnionTypeAnnotation" ||
          parent.type === "TSUnionType" ||
          ((parent.type === "ClassDeclaration" ||
            parent.type === "ClassExpression") &&
            parent.superClass === node)))) &&
    (!hasIgnoreComment(path) ||
      parent.type === "UnionTypeAnnotation" ||
      parent.type === "TSUnionType")
  );
}