@@ -10480,29 +10480,14 @@ namespace ts {
10480
10480
return result;
10481
10481
}
10482
10482
10483
- function isPossiblyReferencedInConditionalType(tp: TypeParameter, node: Node) {
10484
- if (isTypeParameterPossiblyReferenced(tp, node)) {
10485
- return true;
10486
- }
10487
- while (node) {
10488
- if (node.kind === SyntaxKind.ConditionalType) {
10489
- if (isTypeParameterPossiblyReferenced(tp, (<ConditionalTypeNode>node).extendsType)) {
10490
- return true;
10491
- }
10492
- }
10493
- node = node.parent;
10494
- }
10495
- return false;
10496
- }
10497
-
10498
10483
function getTypeFromConditionalTypeNode(node: ConditionalTypeNode): Type {
10499
10484
const links = getNodeLinks(node);
10500
10485
if (!links.resolvedType) {
10501
10486
const checkType = getTypeFromTypeNode(node.checkType);
10502
10487
const aliasSymbol = getAliasSymbolForTypeNode(node);
10503
10488
const aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
10504
10489
const allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true);
10505
- const outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : filter(allOuterTypeParameters, tp => isPossiblyReferencedInConditionalType (tp, node));
10490
+ const outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : filter(allOuterTypeParameters, tp => isTypeParameterPossiblyReferenced (tp, node));
10506
10491
const root: ConditionalRoot = {
10507
10492
node,
10508
10493
checkType,
@@ -11196,9 +11181,12 @@ namespace ts {
11196
11181
// type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
11197
11182
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
11198
11183
const container = tp.symbol.declarations[0].parent;
11199
- if (findAncestor(node, n => n.kind === SyntaxKind.Block ? "quit" : n === container)) {
11200
- return !!forEachChild(node, containsReference);
11184
+ for (let n = node; n !== container; n = n.parent) {
11185
+ if (!n || n.kind === SyntaxKind.Block || n.kind === SyntaxKind.ConditionalType && forEachChild((<ConditionalTypeNode>n).extendsType, containsReference)) {
11186
+ return true;
11187
+ }
11201
11188
}
11189
+ return !!forEachChild(node, containsReference);
11202
11190
}
11203
11191
return true;
11204
11192
function containsReference(node: Node): boolean {
0 commit comments