Skip to content

Commit 671d83e

Browse files
RyanCavanaughbillti
authored andcommitted
Treat multiple prototype property assignments as union property declarations
(cherry picked from commit a4c6f66)
1 parent 5de87e3 commit 671d83e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2845,7 +2845,7 @@ namespace ts {
28452845
}
28462846
// Handle module.exports = expr
28472847
if (declaration.kind === SyntaxKind.BinaryExpression) {
2848-
return links.type = checkExpression((<BinaryExpression>declaration).right);
2848+
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
28492849
}
28502850
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
28512851
// Declarations only exist for property access expressions for certain
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)