diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cc81f92fbfc..1b70275b11c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1435,7 +1435,8 @@ namespace ts { // Declare a 'member' in case it turns out the container was an ES5 class if (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) { container.symbol.members = container.symbol.members || {}; - declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } } diff --git a/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts new file mode 100644 index 00000000000..2524e50e668 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptSemanticDiagnostics23.ts @@ -0,0 +1,14 @@ +/// + +// @allowJs: true +// @Filename: a.js +//// function Person(age) { +//// if (age >= 18) { +//// this.canVote = true; +//// } else { +//// this.canVote = false; +//// } +//// } + +verify.getSyntacticDiagnostics(`[]`); +verify.getSemanticDiagnostics(`[]`);