Skip to content

Commit d093d6a

Browse files
committed
Less aggressive test for type parameter references in conditional types
1 parent 0fd8fb8 commit d093d6a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8430,15 +8430,19 @@ namespace ts {
84308430
return result;
84318431
}
84328432

8433-
function getTopConditionalType(node: Node): ConditionalTypeNode {
8434-
let result: ConditionalTypeNode;
8433+
function isPossiblyReferencedInConditionalType(tp: TypeParameter, node: Node) {
8434+
if (isTypeParameterPossiblyReferenced(tp, node)) {
8435+
return true;
8436+
}
84358437
while (node) {
84368438
if (node.kind === SyntaxKind.ConditionalType) {
8437-
result = <ConditionalTypeNode>node;
8439+
if (isTypeParameterPossiblyReferenced(tp, (<ConditionalTypeNode>node).extendsType)) {
8440+
return true;
8441+
}
84388442
}
84398443
node = node.parent;
84408444
}
8441-
return result;
8445+
return false;
84428446
}
84438447

84448448
function getTypeFromConditionalTypeNode(node: ConditionalTypeNode): Type {
@@ -8447,8 +8451,7 @@ namespace ts {
84478451
const checkType = getTypeFromTypeNode(node.checkType);
84488452
const aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node);
84498453
const allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
8450-
const topNode = getTopConditionalType(node);
8451-
const outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : filter(allOuterTypeParameters, tp => isTypeParameterPossiblyReferenced(tp, topNode));
8454+
const outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : filter(allOuterTypeParameters, tp => isPossiblyReferencedInConditionalType(tp, node));
84528455
const root: ConditionalRoot = {
84538456
node,
84548457
checkType,

0 commit comments

Comments
 (0)