@@ -418,7 +418,7 @@ namespace ts {
418418 return declareSymbol ( container . symbol . exports , container . symbol , node , symbolFlags , symbolExcludes ) ;
419419 }
420420 else {
421- return declareSymbol ( container . locals , undefined , node , symbolFlags , symbolExcludes ) ;
421+ return declareSymbol ( container . locals , /*parent*/ undefined , node , symbolFlags , symbolExcludes ) ;
422422 }
423423 }
424424 else {
@@ -447,13 +447,13 @@ namespace ts {
447447 ( symbolFlags & SymbolFlags . Value ? SymbolFlags . ExportValue : 0 ) |
448448 ( symbolFlags & SymbolFlags . Type ? SymbolFlags . ExportType : 0 ) |
449449 ( symbolFlags & SymbolFlags . Namespace ? SymbolFlags . ExportNamespace : 0 ) ;
450- const local = declareSymbol ( container . locals , undefined , node , exportKind , symbolExcludes ) ;
450+ const local = declareSymbol ( container . locals , /*parent*/ undefined , node , exportKind , symbolExcludes ) ;
451451 local . exportSymbol = declareSymbol ( container . symbol . exports , container . symbol , node , symbolFlags , symbolExcludes ) ;
452452 node . localSymbol = local ;
453453 return local ;
454454 }
455455 else {
456- return declareSymbol ( container . locals , undefined , node , symbolFlags , symbolExcludes ) ;
456+ return declareSymbol ( container . locals , /*parent*/ undefined , node , symbolFlags , symbolExcludes ) ;
457457 }
458458 }
459459 }
@@ -1545,7 +1545,7 @@ namespace ts {
15451545 function declareSourceFileMember ( node : Declaration , symbolFlags : SymbolFlags , symbolExcludes : SymbolFlags ) {
15461546 return isExternalModule ( file )
15471547 ? declareModuleMember ( node , symbolFlags , symbolExcludes )
1548- : declareSymbol ( file . locals , undefined , node , symbolFlags , symbolExcludes ) ;
1548+ : declareSymbol ( file . locals , /*parent*/ undefined , node , symbolFlags , symbolExcludes ) ;
15491549 }
15501550
15511551 function hasExportDeclarations ( node : ModuleDeclaration | SourceFile ) : boolean {
@@ -1721,7 +1721,7 @@ namespace ts {
17211721 blockScopeContainer . locals = createMap < Symbol > ( ) ;
17221722 addToContainerChain ( blockScopeContainer ) ;
17231723 }
1724- declareSymbol ( blockScopeContainer . locals , undefined , node , symbolFlags , symbolExcludes ) ;
1724+ declareSymbol ( blockScopeContainer . locals , /*parent*/ undefined , node , symbolFlags , symbolExcludes ) ;
17251725 }
17261726 }
17271727
@@ -2298,7 +2298,7 @@ namespace ts {
22982298
22992299 function isNameOfExportsOrModuleExportsAliasDeclaration ( node : Node ) {
23002300 if ( node . kind === SyntaxKind . Identifier ) {
2301- const symbol = container . locals . get ( ( < Identifier > node ) . text ) ;
2301+ const symbol = lookupSymbolForName ( ( < Identifier > node ) . text ) ;
23022302 if ( symbol && symbol . valueDeclaration && symbol . valueDeclaration . kind === SyntaxKind . VariableDeclaration ) {
23032303 const declaration = symbol . valueDeclaration as VariableDeclaration ;
23042304 if ( declaration . initializer ) {
@@ -2333,7 +2333,7 @@ namespace ts {
23332333
23342334 function bindThisPropertyAssignment ( node : BinaryExpression ) {
23352335 Debug . assert ( isInJavaScriptFile ( node ) ) ;
2336- const container = getThisContainer ( node , /*includeArrowFunctions*/ false ) ;
2336+ const container = getThisContainer ( node , /*includeArrowFunctions*/ false ) ;
23372337 switch ( container . kind ) {
23382338 case SyntaxKind . FunctionDeclaration :
23392339 case SyntaxKind . FunctionExpression :
@@ -2400,8 +2400,12 @@ namespace ts {
24002400 }
24012401 }
24022402
2403+ function lookupSymbolForName ( name : string ) {
2404+ return ( container . symbol && container . symbol . exports && container . symbol . exports . get ( name ) ) || container . locals . get ( name ) ;
2405+ }
2406+
24032407 function bindPropertyAssignment ( functionName : string , propertyAccessExpression : PropertyAccessExpression , isPrototypeProperty : boolean ) {
2404- let targetSymbol = container . locals . get ( functionName ) ;
2408+ let targetSymbol = lookupSymbolForName ( functionName ) ;
24052409
24062410 if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
24072411 targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
@@ -2423,7 +2427,7 @@ namespace ts {
24232427 function bindCallExpression ( node : CallExpression ) {
24242428 // We're only inspecting call expressions to detect CommonJS modules, so we can skip
24252429 // this check if we've already seen the module indicator
2426- if ( ! file . commonJsModuleIndicator && isRequireCall ( node , /*checkArgumentIsStringLiteral*/ false ) ) {
2430+ if ( ! file . commonJsModuleIndicator && isRequireCall ( node , /*checkArgumentIsStringLiteral*/ false ) ) {
24272431 setCommonJsModuleIndicator ( node ) ;
24282432 }
24292433 }
0 commit comments