diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7351bae1539..49b89904bef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20605,8 +20605,7 @@ namespace ts { } function checkInferType(node: InferTypeNode) { - const ancestor = findAncestor(node, n => n.parent && n.parent.kind === SyntaxKind.ConditionalType); - if (!ancestor || (ancestor.parent).extendsType !== ancestor) { + if (!findAncestor(node, n => n.parent && n.parent.kind === SyntaxKind.ConditionalType && (n.parent).extendsType === n)) { grammarErrorOnNode(node, Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter);