Skip to content

Commit a17f16d

Browse files
committed
Add JS declaration to index constraint check error reporting
Now Javascript-style declarations like `this.foo = "bar"` are handled correctly.
1 parent f43af5e commit a17f16d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20196,7 +20196,10 @@ namespace ts {
2019620196
// perform property check if property or indexer is declared in 'type'
2019720197
// this allows to rule out cases when both property and indexer are inherited from the base class
2019820198
let errorNode: Node;
20199-
if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) {
20199+
if (propDeclaration &&
20200+
(getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression) === SpecialPropertyAssignmentKind.ThisProperty ||
20201+
propDeclaration.name.kind === SyntaxKind.ComputedPropertyName ||
20202+
prop.parent === containingType.symbol)) {
2020020203
errorNode = propDeclaration;
2020120204
}
2020220205
else if (indexDeclaration) {

0 commit comments

Comments
 (0)