@@ -1928,7 +1928,7 @@ namespace ts {
1928
1928
bindThisPropertyAssignment ( < BinaryExpression > node ) ;
1929
1929
break ;
1930
1930
case SpecialPropertyAssignmentKind . Property :
1931
- bindPropertyAssignment ( < BinaryExpression > node ) ;
1931
+ bindStaticPropertyAssignment ( < BinaryExpression > node ) ;
1932
1932
break ;
1933
1933
case SpecialPropertyAssignmentKind . None :
1934
1934
// Nothing to do
@@ -2220,25 +2220,10 @@ namespace ts {
2220
2220
constructorFunction . parent = classPrototype ;
2221
2221
classPrototype . parent = leftSideOfAssignment ;
2222
2222
2223
- let funcSymbol = container . locals . get ( constructorFunction . text ) ;
2224
- if ( funcSymbol && isDeclarationOfFunctionOrClassExpression ( funcSymbol ) ) {
2225
- funcSymbol = ( funcSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
2226
- }
2227
-
2228
- if ( ! funcSymbol || ! ( funcSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) {
2229
- return ;
2230
- }
2231
-
2232
- // Set up the members collection if it doesn't exist already
2233
- if ( ! funcSymbol . members ) {
2234
- funcSymbol . members = createMap < Symbol > ( ) ;
2235
- }
2236
-
2237
- // Declare the method/property
2238
- declareSymbol ( funcSymbol . members , funcSymbol , leftSideOfAssignment , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
2223
+ bindPropertyAssignment ( constructorFunction . text , leftSideOfAssignment , /*isPrototypeProperty*/ true ) ;
2239
2224
}
2240
2225
2241
- function bindPropertyAssignment ( node : BinaryExpression ) {
2226
+ function bindStaticPropertyAssignment ( node : BinaryExpression ) {
2242
2227
// We saw a node of the form 'x.y = z'. Declare a 'member' y on x if x was a function.
2243
2228
2244
2229
// Look up the function in the local scope, since prototype assignments should
@@ -2250,22 +2235,26 @@ namespace ts {
2250
2235
leftSideOfAssignment . parent = node ;
2251
2236
target . parent = leftSideOfAssignment ;
2252
2237
2253
- let funcSymbol = container . locals . get ( target . text ) ;
2254
- if ( funcSymbol && isDeclarationOfFunctionOrClassExpression ( funcSymbol ) ) {
2255
- funcSymbol = ( funcSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
2238
+ bindPropertyAssignment ( target . text , leftSideOfAssignment , /*isPrototypeProperty*/ false ) ;
2239
+ }
2240
+
2241
+ function bindPropertyAssignment ( functionName : string , propertyAccessExpression : PropertyAccessExpression , isPrototypeProperty : boolean ) {
2242
+ let targetSymbol = container . locals . get ( functionName ) ;
2243
+ if ( targetSymbol && isDeclarationOfFunctionOrClassExpression ( targetSymbol ) ) {
2244
+ targetSymbol = ( targetSymbol . valueDeclaration as VariableDeclaration ) . initializer . symbol ;
2256
2245
}
2257
2246
2258
- if ( ! funcSymbol || ! ( funcSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) {
2247
+ if ( ! targetSymbol || ! ( targetSymbol . flags & ( SymbolFlags . Function | SymbolFlags . Class ) ) ) {
2259
2248
return ;
2260
2249
}
2261
2250
2262
2251
// Set up the members collection if it doesn't exist already
2263
- if ( ! funcSymbol . exports ) {
2264
- funcSymbol . exports = createMap < Symbol > ( ) ;
2265
- }
2252
+ const symbolTable = isPrototypeProperty ?
2253
+ ( targetSymbol . members || ( targetSymbol . members = createMap < Symbol > ( ) ) ) :
2254
+ ( targetSymbol . exports || ( targetSymbol . exports = createMap < Symbol > ( ) ) ) ;
2266
2255
2267
2256
// Declare the method/property
2268
- declareSymbol ( funcSymbol . exports , funcSymbol , leftSideOfAssignment , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
2257
+ declareSymbol ( symbolTable , targetSymbol , propertyAccessExpression , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
2269
2258
}
2270
2259
2271
2260
function bindCallExpression ( node : CallExpression ) {
0 commit comments