Don't crash on computed property in destructure (#26334)

This commit is contained in:
Andy
2018-08-09 15:29:45 -07:00
committed by GitHub
parent fce3d9f34d
commit 55a620c433
6 changed files with 118 additions and 4 deletions

View File

@@ -24379,10 +24379,13 @@ namespace ts {
const parentType = getTypeForBindingElementParent(parent);
const name = node.propertyName || node.name;
if (!isBindingPattern(name)) {
const property = getPropertyOfType(parentType!, getTextOfPropertyName(name))!; // TODO: GH#18217
markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference.
if (parent.initializer && property) {
checkPropertyAccessibility(parent, parent.initializer, parentType!, property);
const nameText = getTextOfPropertyName(name);
if (nameText) {
const property = getPropertyOfType(parentType!, nameText)!; // TODO: GH#18217
markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference.
if (parent.initializer && property) {
checkPropertyAccessibility(parent, parent.initializer, parentType!, property);
}
}
}
}