@@ -2238,23 +2238,31 @@ namespace ts {
22382238
22392239 function bindThisPropertyAssignment ( node : BinaryExpression ) {
22402240 Debug . assert ( isInJavaScriptFile ( node ) ) ;
2241- // Declare a 'member' if the container is an ES5 class or ES6 constructor
2242- if ( container . kind === SyntaxKind . FunctionDeclaration || container . kind === SyntaxKind . FunctionExpression ) {
2243- container . symbol . members = container . symbol . members || createMap < Symbol > ( ) ;
2244- // It's acceptable for multiple 'this' assignments of the same identifier to occur
2245- declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2246- }
2247- else if ( container . kind === SyntaxKind . Constructor ) {
2248- // this.foo assignment in a JavaScript class
2249- // Bind this property to the containing class
2250- const saveContainer = container ;
2251- container = container . parent ;
2252- const symbol = bindPropertyOrMethodOrAccessor ( node , SymbolFlags . Property , SymbolFlags . None ) ;
2253- if ( symbol ) {
2254- // constructor-declared symbols can be overwritten by subsequent method declarations
2255- ( symbol as Symbol ) . isReplaceableByMethod = true ;
2256- }
2257- container = saveContainer ;
2241+ switch ( container . kind ) {
2242+ case SyntaxKind . FunctionDeclaration :
2243+ case SyntaxKind . FunctionExpression :
2244+ // Declare a 'member' if the container is an ES5 class or ES6 constructor
2245+ container . symbol . members = container . symbol . members || createMap < Symbol > ( ) ;
2246+ // It's acceptable for multiple 'this' assignments of the same identifier to occur
2247+ declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
2248+ break ;
2249+
2250+ case SyntaxKind . Constructor :
2251+ case SyntaxKind . MethodDeclaration :
2252+ case SyntaxKind . GetAccessor :
2253+ case SyntaxKind . SetAccessor :
2254+ // this.foo assignment in a JavaScript class
2255+ // Bind this property to the containing class
2256+ const containingClass = container . parent ;
2257+ const symbol = hasModifier ( container , ModifierFlags . Static )
2258+ ? declareSymbol ( containingClass . symbol . exports , containingClass . symbol , node , SymbolFlags . Property , SymbolFlags . None )
2259+ : declareSymbol ( containingClass . symbol . members , containingClass . symbol , node , SymbolFlags . Property , SymbolFlags . None ) ;
2260+
2261+ if ( symbol ) {
2262+ // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations
2263+ ( symbol as Symbol ) . isReplaceableByMethod = true ;
2264+ }
2265+ break ;
22582266 }
22592267 }
22602268
0 commit comments