@@ -101,7 +101,6 @@ namespace ts {
101
101
HasLocals = 1 << 5 ,
102
102
IsInterface = 1 << 6 ,
103
103
IsObjectLiteralOrClassExpressionMethod = 1 << 7 ,
104
- IsInferenceContainer = 1 << 8 ,
105
104
}
106
105
107
106
const binder = createBinder ( ) ;
@@ -121,7 +120,6 @@ namespace ts {
121
120
let container : Node ;
122
121
let containerContainer : Node ; // Container one level up
123
122
let blockScopeContainer : Node ;
124
- let inferenceContainer : Node ;
125
123
let lastContainer : Node ;
126
124
let seenThisKeyword : boolean ;
127
125
@@ -190,7 +188,6 @@ namespace ts {
190
188
container = undefined ;
191
189
containerContainer = undefined ;
192
190
blockScopeContainer = undefined ;
193
- inferenceContainer = undefined ;
194
191
lastContainer = undefined ;
195
192
seenThisKeyword = false ;
196
193
currentFlow = undefined ;
@@ -569,13 +566,6 @@ namespace ts {
569
566
bindChildren ( node ) ;
570
567
node . flags = seenThisKeyword ? node . flags | NodeFlags . ContainsThis : node . flags & ~ NodeFlags . ContainsThis ;
571
568
}
572
- else if ( containerFlags & ContainerFlags . IsInferenceContainer ) {
573
- const saveInferenceContainer = inferenceContainer ;
574
- inferenceContainer = node ;
575
- node . locals = undefined ;
576
- bindChildren ( node ) ;
577
- inferenceContainer = saveInferenceContainer ;
578
- }
579
569
else {
580
570
bindChildren ( node ) ;
581
571
}
@@ -1434,9 +1424,6 @@ namespace ts {
1434
1424
case SyntaxKind . MappedType :
1435
1425
return ContainerFlags . IsContainer | ContainerFlags . HasLocals ;
1436
1426
1437
- case SyntaxKind . ConditionalType :
1438
- return ContainerFlags . IsInferenceContainer ;
1439
-
1440
1427
case SyntaxKind . SourceFile :
1441
1428
return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals ;
1442
1429
@@ -2638,13 +2625,25 @@ namespace ts {
2638
2625
: declareSymbolAndAddToSymbolTable ( node , symbolFlags , symbolExcludes ) ;
2639
2626
}
2640
2627
2628
+ function getInferTypeContainer ( node : Node ) : ConditionalTypeNode {
2629
+ while ( node ) {
2630
+ const parent = node . parent ;
2631
+ if ( parent && parent . kind === SyntaxKind . ConditionalType && ( < ConditionalTypeNode > parent ) . extendsType === node ) {
2632
+ return < ConditionalTypeNode > parent ;
2633
+ }
2634
+ node = parent ;
2635
+ }
2636
+ return undefined ;
2637
+ }
2638
+
2641
2639
function bindTypeParameter ( node : TypeParameterDeclaration ) {
2642
2640
if ( node . parent . kind === SyntaxKind . InferType ) {
2643
- if ( inferenceContainer ) {
2644
- if ( ! inferenceContainer . locals ) {
2645
- inferenceContainer . locals = createSymbolTable ( ) ;
2641
+ const container = getInferTypeContainer ( node . parent ) ;
2642
+ if ( container ) {
2643
+ if ( ! container . locals ) {
2644
+ container . locals = createSymbolTable ( ) ;
2646
2645
}
2647
- declareSymbol ( inferenceContainer . locals , /*parent*/ undefined , node , SymbolFlags . TypeParameter , SymbolFlags . TypeParameterExcludes ) ;
2646
+ declareSymbol ( container . locals , /*parent*/ undefined , node , SymbolFlags . TypeParameter , SymbolFlags . TypeParameterExcludes ) ;
2648
2647
}
2649
2648
else {
2650
2649
bindAnonymousDeclaration ( node , SymbolFlags . TypeParameter , getDeclarationName ( node ) ) ;
0 commit comments