mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Move checkClassPropertyAccess call to checkVariableLikeDeclaration
This commit is contained in:
+10
-7
@@ -2607,8 +2607,7 @@ namespace ts {
|
||||
// Return the inferred type for a binding element
|
||||
function getTypeForBindingElement(declaration: BindingElement): Type {
|
||||
const pattern = <BindingPattern>declaration.parent;
|
||||
const parent = <VariableLikeDeclaration>pattern.parent;
|
||||
const parentType = getTypeForBindingElementParent(parent);
|
||||
const parentType = getTypeForBindingElementParent(<VariableLikeDeclaration>pattern.parent);
|
||||
// If parent has the unknown (error) type, then so does this binding element
|
||||
if (parentType === unknownType) {
|
||||
return unknownType;
|
||||
@@ -2643,11 +2642,6 @@ namespace ts {
|
||||
error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name));
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
const property = getPropertyOfType(parentType, text);
|
||||
if (parent && parent.initializer && property && getParentOfSymbol(property)) {
|
||||
checkClassPropertyAccess(parent, parent.initializer, parentType, property);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This elementType will be used if the specific property corresponding to this index is not
|
||||
@@ -13314,6 +13308,15 @@ namespace ts {
|
||||
if (node.propertyName && node.propertyName.kind === SyntaxKind.ComputedPropertyName) {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.propertyName);
|
||||
}
|
||||
|
||||
// check private/protected variable access
|
||||
const parent = <VariableLikeDeclaration>(<BindingPattern>node.parent).parent;
|
||||
const parentType = getTypeForBindingElementParent(parent);
|
||||
const name = node.propertyName || <Identifier>node.name;
|
||||
const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
|
||||
if (parent.initializer && property && getParentOfSymbol(property)) {
|
||||
checkClassPropertyAccess(parent, parent.initializer, parentType, property);
|
||||
}
|
||||
}
|
||||
|
||||
// For a binding pattern, check contained binding elements
|
||||
|
||||
Reference in New Issue
Block a user