@@ -273,6 +273,9 @@ namespace ts {
273273 return getEscapedTextOfIdentifierOrLiteral ( < Identifier | LiteralExpression > name ) ;
274274 }
275275 switch ( node . kind ) {
276+ case SyntaxKind . Identifier :
277+ // THIS IS WRONG
278+ return ( node as any as Identifier ) . escapedText ;
276279 case SyntaxKind . Constructor :
277280 return InternalSymbolName . Constructor ;
278281 case SyntaxKind . FunctionType :
@@ -2354,7 +2357,7 @@ namespace ts {
23542357 constructorFunction . parent = classPrototype ;
23552358 classPrototype . parent = leftSideOfAssignment ;
23562359
2357- bindPropertyAssignment ( constructorFunction . escapedText , leftSideOfAssignment , /*isPrototypeProperty*/ true ) ;
2360+ bindPropertyAssignment ( constructorFunction . escapedText , leftSideOfAssignment , /*isPrototypeProperty*/ true , /*isMagic*/ false ) ;
23582361 }
23592362
23602363 function bindStaticPropertyAssignment ( node : BinaryExpression ) {
@@ -2377,7 +2380,7 @@ namespace ts {
23772380 bindExportsPropertyAssignment ( node ) ;
23782381 }
23792382 else {
2380- bindPropertyAssignment ( target . escapedText , leftSideOfAssignment , /*isPrototypeProperty*/ false ) ;
2383+ bindPropertyAssignment ( target . escapedText , leftSideOfAssignment , /*isPrototypeProperty*/ false , /*isMagic*/ true ) ;
23812384 }
23822385 }
23832386 }
@@ -2386,14 +2389,22 @@ namespace ts {
23862389 return ( container . symbol && container . symbol . exports && container . symbol . exports . get ( name ) ) || ( container . locals && container . locals . get ( name ) ) ;
23872390 }
23882391
2389- function bindPropertyAssignment ( functionName : __String , propertyAccessExpression : PropertyAccessExpression , isPrototypeProperty : boolean ) {
2392+ function bindPropertyAssignment ( functionName : __String , propertyAccessExpression : PropertyAccessExpression , isPrototypeProperty : boolean , isMagic : boolean ) {
23902393 let targetSymbol = lookupSymbolForName ( functionName ) ;
2391-
23922394 if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
23932395 targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
23942396 }
2395-
2396- if ( ! targetSymbol || ! ( targetSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) {
2397+ if ( isMagic && ( ! targetSymbol || ! ( targetSymbol . flags & SymbolFlags . Namespace ) ) ) {
2398+ // TODO: Magic may not be required
2399+ // TODO: Container.locals as symbolTable is probably wrong sometimes (maybe it's sometimes exports?)
2400+ // TODO: Container.symbol as parent is probably wrong sometimes
2401+ // TODO: propertyAccessExpression.expression isn't a Declaration
2402+ targetSymbol = declareSymbol ( container . locals , container . symbol , propertyAccessExpression . expression as any as Declaration , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes ) ;
2403+ }
2404+ if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
2405+ targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
2406+ }
2407+ if ( ! isMagic && ( ! targetSymbol || ! ( targetSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) ) {
23972408 return ;
23982409 }
23992410
0 commit comments