Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`: 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`) 2. For `a?.b!`, the outermost chain is `a?.b` (`b` is the end of the chain starting at `a?.`) 3. For `(a
(node *Expression)
| 373 | // 5. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is |
| 374 | // the end of the chain starting at `a?.`) |
| 375 | func IsOutermostOptionalChain(node *Expression) bool { |
| 376 | parent := node.Parent |
| 377 | return !IsOptionalChain(parent) || // cases 1, 2, and 3 |
| 378 | IsOptionalChainRoot(parent) || // case 4 |
| 379 | node != parent.Expression() // case 5 |
| 380 | } |
| 381 | |
| 382 | // Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). |
| 383 | func IsExpressionOfOptionalChainRoot(node *Node) bool { |
no test coverage detected