mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 17:30:04 -05:00
Parse error on private identifier optional chain (#35987)
Previously, this error was reported in the checker, so JS files with checkJs: false were not erroring on this invalid syntax.
This commit is contained in:
committed by
Daniel Rosenwasser
parent
9fbcdb1edb
commit
f84b2d20a9
@@ -4680,10 +4680,12 @@ namespace ts {
|
||||
const propertyAccess = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
|
||||
propertyAccess.expression = expression;
|
||||
propertyAccess.questionDotToken = questionDotToken;
|
||||
// checker will error on private identifiers in optional chains, so don't have to catch them here
|
||||
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true);
|
||||
if (questionDotToken || expression.flags & NodeFlags.OptionalChain) {
|
||||
propertyAccess.flags |= NodeFlags.OptionalChain;
|
||||
if (isPrivateIdentifier(propertyAccess.name)) {
|
||||
parseErrorAtRange(propertyAccess.name, Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
|
||||
}
|
||||
}
|
||||
return finishNode(propertyAccess);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user