Treat multiple prototype property assignments as union property declarations

(cherry picked from commit a4c6f66686)
This commit is contained in:
Ryan Cavanaugh
2016-02-04 11:26:02 -08:00
committed by Bill Ticehurst
parent 5de87e30c6
commit 671d83e81a
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -2845,7 +2845,7 @@ namespace ts {
}
// Handle module.exports = expr
if (declaration.kind === SyntaxKind.BinaryExpression) {
return links.type = checkExpression((<BinaryExpression>declaration).right);
return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
}
if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
// Declarations only exist for property access expressions for certain
@@ -0,0 +1,16 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
//// function Person(age) {
//// if (age >= 18) {
//// this.canVote = true;
//// } else {
//// this.canVote = 23;
//// }
//// }
//// let x = new Person(100);
//// x.canVote/**/;
goTo.marker();
verify.quickInfoIs('(property) Person.canVote: boolean | number');