Treat multiple prototype property assignments as union property declarations

This commit is contained in:
Ryan Cavanaugh
2016-02-01 20:59:37 -08:00
parent 7259b9fd4a
commit a4c6f66686
2 changed files with 17 additions and 1 deletions

View File

@@ -2827,7 +2827,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

View File

@@ -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');