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

Method bindOptionalChainFlow

internal/binder/binder.go:2346–2361  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

2344}
2345
2346func (b *Binder) bindOptionalChainFlow(node *ast.Node) {
2347 if isTopLevelLogicalExpression(node) {
2348 postExpressionLabel := b.createBranchLabel()
2349 saveCurrentFlow := b.currentFlow
2350 saveHasFlowEffects := b.hasFlowEffects
2351 b.bindOptionalChain(node, postExpressionLabel, postExpressionLabel)
2352 if b.hasFlowEffects {
2353 b.currentFlow = b.finishFlowLabel(postExpressionLabel)
2354 } else {
2355 b.currentFlow = saveCurrentFlow
2356 }
2357 b.hasFlowEffects = b.hasFlowEffects || saveHasFlowEffects
2358 } else {
2359 b.bindOptionalChain(node, b.currentTrueTarget, b.currentFalseTarget)
2360 }
2361}
2362
2363func (b *Binder) bindOptionalChain(node *ast.Node, trueTarget *ast.FlowLabel, falseTarget *ast.FlowLabel) {
2364 // For an optional chain, we emulate the behavior of a logical expression:

Callers 3

Calls 4

createBranchLabelMethod · 0.95
bindOptionalChainMethod · 0.95
finishFlowLabelMethod · 0.95

Tested by

no test coverage detected