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

Method createFlowCondition

internal/binder/binder.go:479–497  ·  view source on GitHub ↗
(flags ast.FlowFlags, antecedent *ast.FlowNode, expression *ast.Node)

Source from the content-addressed store, hash-verified

477}
478
479func (b *Binder) createFlowCondition(flags ast.FlowFlags, antecedent *ast.FlowNode, expression *ast.Node) *ast.FlowNode {
480 if antecedent.Flags&ast.FlowFlagsUnreachable != 0 {
481 return antecedent
482 }
483 if expression == nil {
484 if flags&ast.FlowFlagsTrueCondition != 0 {
485 return antecedent
486 }
487 return b.unreachableFlow
488 }
489 if (expression.Kind == ast.KindTrueKeyword && flags&ast.FlowFlagsFalseCondition != 0 || expression.Kind == ast.KindFalseKeyword && flags&ast.FlowFlagsTrueCondition != 0) && !ast.IsExpressionOfOptionalChainRoot(expression) && !ast.IsNullishCoalesce(expression.Parent) {
490 return b.unreachableFlow
491 }
492 if !isNarrowingExpression(expression) {
493 return antecedent
494 }
495 setFlowNodeReferenced(antecedent)
496 return b.newFlowNodeEx(flags, expression, antecedent)
497}
498
499func (b *Binder) createFlowMutation(flags ast.FlowFlags, antecedent *ast.FlowNode, node *ast.Node) *ast.FlowNode {
500 setFlowNodeReferenced(antecedent)

Callers 4

bindConditionMethod · 0.95
bindOptionalChainMethod · 0.95

Calls 5

newFlowNodeExMethod · 0.95
IsNullishCoalesceFunction · 0.92
isNarrowingExpressionFunction · 0.85
setFlowNodeReferencedFunction · 0.85

Tested by

no test coverage detected