@@ -118,7 +118,7 @@ namespace ts {
118
118
let languageVersion : ScriptTarget ;
119
119
let parent : Node ;
120
120
let container : Node ;
121
- let containerContainer : Node ; // Container one level up
121
+ let thisParentContainer : Node ; // Container one level up
122
122
let blockScopeContainer : Node ;
123
123
let lastContainer : Node ;
124
124
let seenThisKeyword : boolean ;
@@ -186,7 +186,7 @@ namespace ts {
186
186
languageVersion = undefined ;
187
187
parent = undefined ;
188
188
container = undefined ;
189
- containerContainer = undefined ;
189
+ thisParentContainer = undefined ;
190
190
blockScopeContainer = undefined ;
191
191
lastContainer = undefined ;
192
192
seenThisKeyword = false ;
@@ -479,11 +479,9 @@ namespace ts {
479
479
// and block-container. Then after we pop out of processing the children, we restore
480
480
// these saved values.
481
481
const saveContainer = container ;
482
- const saveContainerContainer = containerContainer ;
482
+ const saveThisParentContainer = thisParentContainer ;
483
483
const savedBlockScopeContainer = blockScopeContainer ;
484
484
485
- containerContainer = container ;
486
-
487
485
// Depending on what kind of node this is, we may have to adjust the current container
488
486
// and block-container. If the current node is a container, then it is automatically
489
487
// considered the current block-container as well. Also, for containers that we know
@@ -502,6 +500,9 @@ namespace ts {
502
500
// for it. We must clear this so we don't accidentally move any stale data forward from
503
501
// a previous compilation.
504
502
if ( containerFlags & ContainerFlags . IsContainer ) {
503
+ if ( node . kind !== SyntaxKind . ArrowFunction ) {
504
+ thisParentContainer = container ;
505
+ }
505
506
container = blockScopeContainer = node ;
506
507
if ( containerFlags & ContainerFlags . HasLocals ) {
507
508
container . locals = createSymbolTable ( ) ;
@@ -571,7 +572,7 @@ namespace ts {
571
572
}
572
573
573
574
container = saveContainer ;
574
- containerContainer = saveContainerContainer ;
575
+ thisParentContainer = saveThisParentContainer ;
575
576
blockScopeContainer = savedBlockScopeContainer ;
576
577
}
577
578
@@ -2338,14 +2339,16 @@ namespace ts {
2338
2339
if ( isBinaryExpression ( thisContainer . parent ) && thisContainer . parent . operatorToken . kind === SyntaxKind . EqualsToken ) {
2339
2340
const l = thisContainer . parent . left ;
2340
2341
if ( isPropertyAccessEntityNameExpression ( l ) && isPrototypeAccess ( l . expression ) ) {
2341
- constructorSymbol = getJSInitializerSymbolFromName ( l . expression . expression , containerContainer ) ;
2342
+ constructorSymbol = getJSInitializerSymbolFromName ( l . expression . expression , thisParentContainer ) ;
2342
2343
}
2343
2344
}
2344
2345
2345
- // Declare a 'member' if the container is an ES5 class or ES6 constructor
2346
- constructorSymbol . members = constructorSymbol . members || createSymbolTable ( ) ;
2347
- // It's acceptable for multiple 'this' assignments of the same identifier to occur
2348
- declareSymbol ( constructorSymbol . members , constructorSymbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2346
+ if ( constructorSymbol ) {
2347
+ // Declare a 'member' if the container is an ES5 class or ES6 constructor
2348
+ constructorSymbol . members = constructorSymbol . members || createSymbolTable ( ) ;
2349
+ // It's acceptable for multiple 'this' assignments of the same identifier to occur
2350
+ declareSymbol ( constructorSymbol . members , constructorSymbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2351
+ }
2349
2352
break ;
2350
2353
2351
2354
case SyntaxKind . Constructor :
0 commit comments