@@ -26345,23 +26345,19 @@ namespace ts {
26345
26345
if (!(ctor && ctor.kind === SyntaxKind.Constructor)) {
26346
26346
return true;
26347
26347
}
26348
- // 1. no valueDeclaration -- some kind of synthetic property, don't allow the write
26349
- // 2. normal property declaration -- its parent and the ctor's parent should both be a class
26350
- // 3. parameter property declaration -- its parent should BE the ctor itself
26351
- // 4. this.property assignment in a class -- it should be a binaryexpression, and ctor.parent should be the symbol.parent.valueDeclaration
26352
- // 5. this.property assignment in a ctor func -- it should be a binaryexp, and ctor should be the symbol.parent.valueDeclaration
26353
- // If func.parent is a class and symbol is a (readonly) property of that class, or
26354
- // if func is a constructor and symbol is a (readonly) parameter property declared in it,
26355
- // then symbol is writeable here.
26356
26348
if (symbol.valueDeclaration) {
26357
- const isLocalParameterProperty = ctor === symbol.valueDeclaration.parent ;
26349
+ const isAssignmentDeclaration = isBinaryExpression( symbol.valueDeclaration) ;
26358
26350
const isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
26359
- const isLocalThisPropertyAssignment = symbol.parent && symbol.parent.valueDeclaration === ctor.parent; // TODO: Make sure that symbol.parent is a function and class
26360
- const isLocalThisPropertyAssignmentConstructorFunction = symbol.parent && symbol.parent.valueDeclaration === ctor; // TODO: Make sure that symbol.parent is a function and class
26361
- const isLocalProperty = isLocalPropertyDeclaration || isLocalParameterProperty || isLocalThisPropertyAssignment || isLocalThisPropertyAssignmentConstructorFunction ;
26362
- return !isLocalProperty;
26351
+ const isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
26352
+ const isLocalThisPropertyAssignment = isAssignmentDeclaration && symbol.parent?.valueDeclaration === ctor.parent;
26353
+ const isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration && symbol.parent?.valueDeclaration === ctor;
26354
+ const isWriteableSymbol =
26355
+ isLocalPropertyDeclaration
26356
+ || isLocalParameterProperty
26357
+ || isLocalThisPropertyAssignment
26358
+ || isLocalThisPropertyAssignmentConstructorFunction;
26359
+ return !isWriteableSymbol;
26363
26360
}
26364
- return false;
26365
26361
}
26366
26362
return true;
26367
26363
}
0 commit comments