(pos int, expression *ast.Expression, questionDotToken *ast.Node)
| 5400 | } |
| 5401 | |
| 5402 | func (p *Parser) parsePropertyAccessExpressionRest(pos int, expression *ast.Expression, questionDotToken *ast.Node) *ast.Node { |
| 5403 | name := p.parseRightSideOfDot(true /*allowIdentifierNames*/, true /*allowPrivateIdentifiers*/, true /*allowUnicodeEscapeSequenceInIdentifierName*/) |
| 5404 | isOptionalChain := questionDotToken != nil || p.tryReparseOptionalChain(expression) |
| 5405 | propertyAccess := p.factory.NewPropertyAccessExpression(expression, questionDotToken, name, core.IfElse(isOptionalChain, ast.NodeFlagsOptionalChain, ast.NodeFlagsNone)) |
| 5406 | if isOptionalChain && ast.IsPrivateIdentifier(name) { |
| 5407 | p.parseErrorAtRange(p.skipRangeTrivia(name.Loc), diagnostics.An_optional_chain_cannot_contain_private_identifiers) |
| 5408 | } |
| 5409 | if ast.IsExpressionWithTypeArguments(expression) { |
| 5410 | typeArguments := expression.TypeArgumentList() |
| 5411 | if typeArguments != nil { |
| 5412 | loc := core.NewTextRange(typeArguments.Pos()-1, scanner.SkipTrivia(p.sourceText, typeArguments.End())+1) |
| 5413 | p.parseErrorAtRange(loc, diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access) |
| 5414 | } |
| 5415 | } |
| 5416 | return p.finishNode(propertyAccess, pos) |
| 5417 | } |
| 5418 | |
| 5419 | func (p *Parser) tryReparseOptionalChain(node *ast.Expression) bool { |
| 5420 | if node.Flags&ast.NodeFlagsOptionalChain != 0 { |
no test coverage detected