@@ -274,7 +274,7 @@ namespace ts {
274274 }
275275 switch ( node . kind ) {
276276 case SyntaxKind . Identifier :
277- // THIS IS WRONG
277+ // TODO: THIS IS WRONG
278278 return ( node as any as Identifier ) . escapedText ;
279279 case SyntaxKind . Constructor :
280280 return InternalSymbolName . Constructor ;
@@ -2010,6 +2010,7 @@ namespace ts {
20102010 node . flowNode = currentFlow ;
20112011 }
20122012 if ( isSpecialPropertyDeclaration ( node as PropertyAccessExpression ) ) {
2013+ // TODO: this is wrong now that I allow it anywhere
20132014 bindThisPropertyAssignment ( node as PropertyAccessExpression ) ;
20142015 }
20152016 break ;
@@ -2397,17 +2398,21 @@ namespace ts {
23972398 if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
23982399 targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
23992400 }
2400- if ( isMagic && ( ! targetSymbol || ! ( targetSymbol . flags & SymbolFlags . Namespace ) ) ) {
2401- // TODO: Magic may not be required
2402- // TODO: Container.locals as symbolTable is probably wrong sometimes (maybe it's sometimes exports?)
2403- // TODO: Container.symbol as parent is probably wrong sometimes
2404- // TODO: propertyAccessExpression.expression isn't a Declaration
2405- targetSymbol = declareSymbol ( container . locals , container . symbol , propertyAccessExpression . expression as any as Declaration , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes ) ;
2401+ Debug . assert ( propertyAccessExpression . parent . kind === SyntaxKind . BinaryExpression ) ;
2402+ if ( isMagic &&
2403+ ( ! targetSymbol || ! ( targetSymbol . flags & SymbolFlags . Namespace ) ) &&
2404+ ( ( propertyAccessExpression . parent as BinaryExpression ) . right . kind === SyntaxKind . ClassExpression || ( propertyAccessExpression . parent as BinaryExpression ) . right . kind === SyntaxKind . FunctionExpression ) &&
2405+ propertyAccessExpression . parent . parent . parent . kind === SyntaxKind . SourceFile ) {
2406+ // TODO: Magic may not be required (but is so far)
2407+ Debug . assert ( isIdentifier ( propertyAccessExpression . expression ) ) ;
2408+ // TODO: This should be exports if the tgargetSymbol is found, and already exported, otherwise locals
2409+ const symbolTable = container . symbol && container . symbol . exports ? container . symbol . exports : container . locals ;
2410+ targetSymbol = declareSymbol ( symbolTable , container . symbol , propertyAccessExpression . expression as Identifier , SymbolFlags . NamespaceModule , SymbolFlags . NamespaceModuleExcludes ) ;
24062411 }
24072412 if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
24082413 targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
24092414 }
2410- if ( ! isMagic && ( ! targetSymbol || ! ( targetSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) ) {
2415+ if ( ! targetSymbol || ! ( targetSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class | SymbolFlags . NamespaceModule ) ) ) {
24112416 return ;
24122417 }
24132418
0 commit comments