Repository: prettier/prettier
File: src/language-js/parentheses/needs-parentheses.js (JavaScript)

Code before:
      if (
        path.match(
          (node) => node.type === "TSFunctionType",
          (node, key) =>
            key === "typeAnnotation" && node.type === "TSTypeAnnotation",
          (node, key) =>
            key === "returnType" && node.type === "ArrowFunctionExpression",
        )
      ) {
        return true;
      }
    // fallthrough
    case "TSConditionalType":
    case "TSConstructorType":
    case "ConditionalTypeAnnotation":
      if (
        key === "extendsType" &&
        isConditionalType(node) &&
        parent.type === node.type
      ) {
        return true;
      }

      if (
        key === "constraint" &&
        isConditionalType(node) &&
        parent.type === "TSTypeParameter"
      ) {
        return true;
      }

      if (
        key === "typeAnnotation" &&
        isConditionalType(node) &&
        parent.type === "TypeAnnotation" &&
        path.grandparent.type === "TypeParameter" &&
        path.grandparent.bound === parent
      ) {
        return true;
      }

      if (key === "checkType" && isConditionalType(parent)) {
        return true;
      }

      if (key === "extendsType" && parent.type === "TSConditionalType") {
        let { typeAnnotation } = node.returnType || node.typeAnnotation;

        if (
          typeAnnotation.type === "TSTypePredicate" &&
          typeAnnotation.typeAnnotation

Review comment (suggestion):
```suggestion
        node.type === "TSConditionalType" &&
```

Code after:
      if (
        path.match(
          (node) => node.type === "TSFunctionType",
          (node, key) =>
            key === "typeAnnotation" && node.type === "TSTypeAnnotation",
          (node, key) =>
            key === "returnType" && node.type === "ArrowFunctionExpression",
        )
      ) {
        return true;
      }
    // fallthrough
    case "TSConditionalType":
    case "TSConstructorType":
    case "ConditionalTypeAnnotation":
      if (
        key === "extendsType" &&
        isConditionalType(node) &&
        parent.type === node.type
      ) {
        return true;
      }

      // `const foo = <Foo extends (Bar extends Baz ? A : B)>() => true;`
      //                            ^^^^^^^^^^^^^^^^^^^^^^^
      if (
        (key === "constraint" &&
          node.type === "TSConditionalType" &&
          parent.type === "TSTypeParameter") ||
        (key === "typeAnnotation" &&
          node.type === "ConditionalTypeAnnotation" &&
          parent.type === "TypeAnnotation" &&
          path.grandparent.type === "TypeParameter" &&
          path.grandparent.bound === parent &&
          path.grandparent.usesExtendsBound)
      ) {
        return true;
      }

      if (key === "checkType" && isConditionalType(parent)) {
        return true;
      }

      if (key === "extendsType" && parent.type === "TSConditionalType") {
        let { typeAnnotation } = node.returnType || node.typeAnnotation;

        if (
          typeAnnotation.type === "TSTypePredicate" &&
          typeAnnotation.typeAnnotation
        ) {
          typeAnnotation = typeAnnotation.typeAnnotation.typeAnnotation;