mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 02:21:30 -05:00
Treat multiple prototype property assignments as union property declarations
This commit is contained in:
@@ -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
|
||||
|
||||
16
tests/cases/fourslash/getJavaScriptSemanticDiagnostics24.ts
Normal file
16
tests/cases/fourslash/getJavaScriptSemanticDiagnostics24.ts
Normal 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');
|
||||
Reference in New Issue
Block a user