@@ -2607,8 +2607,7 @@ namespace ts {
2607
2607
// Return the inferred type for a binding element
2608
2608
function getTypeForBindingElement(declaration: BindingElement): Type {
2609
2609
const pattern = <BindingPattern>declaration.parent;
2610
- const parent = <VariableLikeDeclaration>pattern.parent;
2611
- const parentType = getTypeForBindingElementParent(parent);
2610
+ const parentType = getTypeForBindingElementParent(<VariableLikeDeclaration>pattern.parent);
2612
2611
// If parent has the unknown (error) type, then so does this binding element
2613
2612
if (parentType === unknownType) {
2614
2613
return unknownType;
@@ -2643,11 +2642,6 @@ namespace ts {
2643
2642
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name));
2644
2643
return unknownType;
2645
2644
}
2646
-
2647
- const property = getPropertyOfType(parentType, text);
2648
- if (parent && parent.initializer && property && getParentOfSymbol(property)) {
2649
- checkClassPropertyAccess(parent, parent.initializer, parentType, property);
2650
- }
2651
2645
}
2652
2646
else {
2653
2647
// This elementType will be used if the specific property corresponding to this index is not
@@ -13314,6 +13308,15 @@ namespace ts {
13314
13308
if (node.propertyName && node.propertyName.kind === SyntaxKind.ComputedPropertyName) {
13315
13309
checkComputedPropertyName(<ComputedPropertyName>node.propertyName);
13316
13310
}
13311
+
13312
+ // check private/protected variable access
13313
+ const parent = <VariableLikeDeclaration>(<BindingPattern>node.parent).parent;
13314
+ const parentType = getTypeForBindingElementParent(parent);
13315
+ const name = node.propertyName || <Identifier>node.name;
13316
+ const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
13317
+ if (parent.initializer && property && getParentOfSymbol(property)) {
13318
+ checkClassPropertyAccess(parent, parent.initializer, parentType, property);
13319
+ }
13317
13320
}
13318
13321
13319
13322
// For a binding pattern, check contained binding elements
0 commit comments