Skip to content

Commit a4c6f66

Browse files
committed
Treat multiple prototype property assignments as union property declarations
1 parent 7259b9f commit a4c6f66

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
@@ -2827,7 +2827,7 @@ namespace ts {
28272827
}
28282828
// Handle module.exports = expr
28292829
if (declaration.kind === SyntaxKind.BinaryExpression) {
2830-
return links.type = checkExpression((<BinaryExpression>declaration).right);
2830+
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
28312831
}
28322832
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
28332833
// 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)