mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
fix(46824): remove duplicate private identifier errors (#47116)
This commit is contained in:
@@ -28235,12 +28235,18 @@ namespace ts {
|
||||
if (!getContainingClass(privId)) {
|
||||
return grammarErrorOnNode(privId, Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
||||
}
|
||||
if (!isExpressionNode(privId)) {
|
||||
return grammarErrorOnNode(privId, Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression);
|
||||
}
|
||||
if (!getSymbolForPrivateIdentifierExpression(privId)) {
|
||||
return grammarErrorOnNode(privId, Diagnostics.Cannot_find_name_0, idText(privId));
|
||||
|
||||
if (!isForInStatement(privId.parent)) {
|
||||
if (!isExpressionNode(privId)) {
|
||||
return grammarErrorOnNode(privId, Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression);
|
||||
}
|
||||
|
||||
const isInOperation = isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === SyntaxKind.InKeyword;
|
||||
if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) {
|
||||
return grammarErrorOnNode(privId, Diagnostics.Cannot_find_name_0, idText(privId));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user