src/language-js/printer-estree.js/printDanglingCommentsForInline
function printTypeParameters(path, options, print, paramsKey) {
  const n = path.getValue();

  if (!n[paramsKey]) {
    return "";
  }

  // for TypeParameterDeclaration typeParameters is a single node
  if (!Array.isArray(n[paramsKey])) {
    return path.call(print, paramsKey);
  }

  const grandparent = path.getNode(2);
  const greatGrandParent = path.getNode(3);
  const greatGreatGrandParent = path.getNode(4);

  const isParameterInTestCall = grandparent != null && isTestCall(grandparent);

  const shouldInline =
    isParameterInTestCall ||
    n[paramsKey].length === 0 ||
    (n[paramsKey].length === 1 &&
      (shouldHugType(n[paramsKey][0]) ||
        (n[paramsKey][0].type === "GenericTypeAnnotation" &&
          shouldHugType(n[paramsKey][0].id)) ||
        (n[paramsKey][0].type === "TSTypeReference" &&
          shouldHugType(n[paramsKey][0].typeName)) ||
        n[paramsKey][0].type === "NullableTypeAnnotation" ||
        // See https://github.com/prettier/prettier/pull/6467 for the context.
        (greatGreatGrandParent &&
          greatGreatGrandParent.type === "VariableDeclarator" &&
          grandparent.type === "TSTypeAnnotation" &&
          greatGrandParent.type !== "ArrowFunctionExpression" &&
          n[paramsKey][0].type !== "TSUnionType" &&
          n[paramsKey][0].type !== "UnionTypeAnnotation" &&
          n[paramsKey][0].type !== "TSIntersectionType" &&
          n[paramsKey][0].type !== "IntersectionTypeAnnotation" &&
          n[paramsKey][0].type !== "TSConditionalType" &&
          n[paramsKey][0].type !== "TSMappedType" &&
          n[paramsKey][0].type !== "TSTypeOperator" &&
          n[paramsKey][0].type !== "TSIndexedAccessType" &&
          n[paramsKey][0].type !== "TSArrayType")));

  function printDanglingCommentsForInline(n) {
    if (!hasDanglingComments(n)) {
      return "";
    }
    const hasOnlyBlockComments = n.comments.every(
      handleComments.isBlockComment
    );
    const printed = comments.printDanglingComments(
      path,
      options,
      /* sameIndent */ hasOnlyBlockComments
    );
    if (hasOnlyBlockComments) {
      return printed;
    }
    return concat([printed, hardline]);
  }

  if (shouldInline) {
    return concat([
      "<",
      join(", ", path.map(print, paramsKey)),
      printDanglingCommentsForInline(n),
      ">",
    ]);
  }

  return group(
    concat([
      "<",
      indent(
        concat([
          softline,
          join(concat([",", line]), path.map(print, paramsKey)),
        ])
      ),
      ifBreak(
        options.parser !== "typescript" &&
          options.parser !== "babel-ts" &&
          shouldPrintComma(options, "all")
          ? ","
          : ""
      ),
      softline,
      ">",
    ])
  );
}