@@ -313,6 +313,11 @@ namespace ts {
313
313
// declaration we have for this symbol, and then create a new symbol for this
314
314
// declaration.
315
315
//
316
+ // Note that when properties declared in Javascript constructors
317
+ // (marked by isReplaceableByMethod) conflict with another symbol, the property loses.
318
+ // Always. This allows the common Javascript pattern of overwriting a prototype method
319
+ // with an bound instance method of the same type: `this.method = this.method.bind(this)`
320
+ //
316
321
// If we created a new symbol, either because we didn't have a symbol with this name
317
322
// in the symbol table, or we conflicted with an existing symbol, then just add this
318
323
// node as the sole declaration of the new symbol.
@@ -329,7 +334,7 @@ namespace ts {
329
334
}
330
335
331
336
if ( symbol . flags & excludes ) {
332
- if ( symbol . isDiscardable ) {
337
+ if ( symbol . isReplaceableByMethod ) {
333
338
// Javascript constructor-declared symbols can be discarded in favor of
334
339
// prototype symbols like methods.
335
340
symbol = symbolTable [ name ] = createSymbol ( SymbolFlags . None , name ) ;
@@ -1988,7 +1993,7 @@ namespace ts {
1988
1993
// It's acceptable for multiple 'this' assignments of the same identifier to occur
1989
1994
// AND it can be overwritten by subsequent method declarations
1990
1995
const symbol = declareSymbol ( assignee . symbol . members , assignee . symbol , node , SymbolFlags . Property , SymbolFlags . PropertyExcludes & ~ SymbolFlags . Property ) ;
1991
- symbol . isDiscardable = true ;
1996
+ symbol . isReplaceableByMethod = true ;
1992
1997
}
1993
1998
1994
1999
function bindPrototypePropertyAssignment ( node : BinaryExpression ) {
0 commit comments