Skip to content

Commit 49fd1ad

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 e1c97e1 commit 49fd1ad

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
@@ -20233,7 +20233,10 @@ namespace ts {
2023320233
// perform property check if property or indexer is declared in 'type'
2023420234
// this allows to rule out cases when both property and indexer are inherited from the base class
2023520235
let errorNode: Node;
20236-
if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) {
20236+
if (propDeclaration &&
20237+
(getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression) === SpecialPropertyAssignmentKind.ThisProperty ||
20238+
propDeclaration.name.kind === SyntaxKind.ComputedPropertyName ||
20239+
prop.parent === containingType.symbol)) {
2023720240
errorNode = propDeclaration;
2023820241
}
2023920242
else if (indexDeclaration) {

0 commit comments

Comments
 (0)