Skip to content

Commit 4721b91

Browse files
committed
Fix multiple Salsa assignment-declarations
Previously, all assignment-declarations needed to be of the same kind: either all `this.p = ...` assignments or `C.prototype.p = ...` assignments.
1 parent f0d5ff6 commit 4721b91

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,17 +3166,17 @@ namespace ts {
31663166
}
31673167

31683168
let type: Type = undefined;
3169-
// Handle module.exports = expr or this.p = expr
3170-
if (declaration.kind === SyntaxKind.BinaryExpression) {
3171-
type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right)));
3172-
}
3173-
else if (declaration.kind === SyntaxKind.PropertyAccessExpression) {
3174-
// Declarations only exist for property access expressions for certain
3175-
// special assignment kinds
3176-
if (declaration.parent.kind === SyntaxKind.BinaryExpression) {
3177-
// Handle exports.p = expr or className.prototype.method = expr
3178-
type = checkExpressionCached((<BinaryExpression>declaration.parent).right);
3179-
}
3169+
// Handle certain special assignment kinds, which happen to union across multiple declarations:
3170+
// * module.exports = expr
3171+
// * exports.p = expr
3172+
// * this.p = expr
3173+
// * className.prototype.method = expr
3174+
if (declaration.kind === SyntaxKind.BinaryExpression ||
3175+
declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
3176+
type = getUnionType(map(symbol.declarations,
3177+
decl => decl.kind === SyntaxKind.BinaryExpression ?
3178+
checkExpressionCached((<BinaryExpression>decl).right) :
3179+
checkExpressionCached((<BinaryExpression>decl.parent).right)));
31803180
}
31813181

31823182
if (type === undefined) {

0 commit comments

Comments
 (0)