@@ -1367,42 +1367,31 @@ namespace ts {
13671367 }
13681368
13691369 function bindThisPropertyAssignment ( node : BinaryExpression ) {
1370+ // Declare a 'member' in case it turns out the container was an ES5 class
13701371 if ( container . kind === SyntaxKind . FunctionExpression || container . kind === SyntaxKind . FunctionDeclaration ) {
13711372 container . symbol . members = container . symbol . members || { } ;
1372- declareClassMember ( node , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
1373+ declareSymbol ( container . symbol . members , container . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
13731374 }
13741375 }
13751376
13761377 function bindPrototypePropertyAssignment ( node : BinaryExpression ) {
1377- // We saw a node of the form 'x.prototype.y = z'.
1378- // This does two things: turns 'x' into a constructor function, and
1379- // adds a member 'y' to the result of that constructor function
1380- // Get 'x', the class
1381- const classId = < Identifier > ( < PropertyAccessExpression > ( < PropertyAccessExpression > node . left ) . expression ) . expression ;
1378+ // We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function.
13821379
1383- // Look up the function in the local scope, since prototype assignments should immediately
1380+ // Look up the function in the local scope, since prototype assignments should
13841381 // follow the function declaration
1382+ const classId = < Identifier > ( < PropertyAccessExpression > ( < PropertyAccessExpression > node . left ) . expression ) . expression ;
13851383 const funcSymbol = container . locals [ classId . text ] ;
1386- if ( ! funcSymbol ) {
1384+ if ( ! funcSymbol || ! ( funcSymbol . flags & SymbolFlags . Function ) ) {
13871385 return ;
13881386 }
13891387
1390- // The function is now a constructor rather than a normal function
1391- if ( ! funcSymbol . inferredConstructor ) {
1392- // Have the binder set up all the related class symbols for us
1393- declareSymbol ( container . locals , funcSymbol , funcSymbol . valueDeclaration , SymbolFlags . Class , SymbolFlags . None ) ;
1394- // funcSymbol.members = funcSymbol.members || {};
1395- funcSymbol . members [ "__constructor" ] = funcSymbol ;
1396- funcSymbol . inferredConstructor = true ;
1388+ // Set up the members collection if it doesn't exist already
1389+ if ( ! funcSymbol . members ) {
1390+ funcSymbol . members = { } ;
13971391 }
13981392
1399- // Get the exports of the class so we can add the method to it
1400- const funcExports = declareSymbol ( funcSymbol . exports , funcSymbol , < PropertyAccessExpression > ( < PropertyAccessExpression > node . left ) . expression , SymbolFlags . ObjectLiteral | SymbolFlags . Property , SymbolFlags . None ) ;
1401-
1402- // Declare the method
1403- declareSymbol ( funcExports . members , funcExports , < PropertyAccessExpression > node . left , SymbolFlags . Method , SymbolFlags . None ) ;
1404- // and on the members of the function so it appears in 'prototype'
1405- declareSymbol ( funcSymbol . members , funcSymbol , < PropertyAccessExpression > node . left , SymbolFlags . Method , SymbolFlags . PropertyExcludes ) ;
1393+ // Declare the method/property
1394+ declareSymbol ( funcSymbol . members , funcSymbol , < PropertyAccessExpression > node . left , SymbolFlags . Property , SymbolFlags . PropertyExcludes ) ;
14061395 }
14071396
14081397 function bindCallExpression ( node : CallExpression ) {
0 commit comments