Skip to content

Commit 554ea1b

Browse files
committed
Merge pull request #6679 from RyanCavanaugh/fix6645
Allow multiple 'this' property assignments in Salsa
2 parents 3dae253 + a4c6f66 commit 554ea1b

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,8 @@ namespace ts {
14351435
// Declare a 'member' in case it turns out the container was an ES5 class
14361436
if (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.FunctionDeclaration) {
14371437
container.symbol.members = container.symbol.members || {};
1438-
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
1438+
// It's acceptable for multiple 'this' assignments of the same identifier to occur
1439+
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
14391440
}
14401441
}
14411442

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ namespace ts {
28372837
}
28382838
// Handle module.exports = expr
28392839
if (declaration.kind === SyntaxKind.BinaryExpression) {
2840-
return links.type = checkExpression((<BinaryExpression>declaration).right);
2840+
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
28412841
}
28422842
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
28432843
// Declarations only exist for property access expressions for certain
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @Filename: a.js
5+
//// function Person(age) {
6+
//// if (age >= 18) {
7+
//// this.canVote = true;
8+
//// } else {
9+
//// this.canVote = false;
10+
//// }
11+
//// }
12+
13+
verify.getSyntacticDiagnostics(`[]`);
14+
verify.getSemanticDiagnostics(`[]`);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @Filename: a.js
5+
//// function Person(age) {
6+
//// if (age >= 18) {
7+
//// this.canVote = true;
8+
//// } else {
9+
//// this.canVote = 23;
10+
//// }
11+
//// }
12+
//// let x = new Person(100);
13+
//// x.canVote/**/;
14+
15+
goTo.marker();
16+
verify.quickInfoIs('(property) Person.canVote: boolean | number');

0 commit comments

Comments
 (0)