MCPcopy Create free account
hub / github.com/microsoft/typescript-go / tryReparseOptionalChain

Method tryReparseOptionalChain

internal/parser/parser.go:5419–5439  ·  view source on GitHub ↗
(node *ast.Expression)

Source from the content-addressed store, hash-verified

5417}
5418
5419func (p *Parser) tryReparseOptionalChain(node *ast.Expression) bool {
5420 if node.Flags&ast.NodeFlagsOptionalChain != 0 {
5421 return true
5422 }
5423 // check for an optional chain in a non-null expression
5424 if ast.IsNonNullExpression(node) {
5425 expr := node.Expression()
5426 for ast.IsNonNullExpression(expr) && expr.Flags&ast.NodeFlagsOptionalChain == 0 {
5427 expr = expr.Expression()
5428 }
5429 if expr.Flags&ast.NodeFlagsOptionalChain != 0 {
5430 // this is part of an optional chain. Walk down from `node` to `expression` and set the flag.
5431 for ast.IsNonNullExpression(node) {
5432 node.Flags |= ast.NodeFlagsOptionalChain
5433 node = node.Expression()
5434 }
5435 return true
5436 }
5437 }
5438 return false
5439}
5440
5441func (p *Parser) parseElementAccessExpressionRest(pos int, expression *ast.Expression, questionDotToken *ast.Node) *ast.Node {
5442 var argumentExpression *ast.Expression

Calls 2

IsNonNullExpressionFunction · 0.92
ExpressionMethod · 0.80

Tested by

no test coverage detected