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

Function isNarrowableReference

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

Source from the content-addressed store, hash-verified

2631}
2632
2633func isNarrowableReference(node *ast.Node) bool {
2634 switch node.Kind {
2635 case ast.KindIdentifier, ast.KindThisKeyword, ast.KindSuperKeyword, ast.KindMetaProperty:
2636 return true
2637 case ast.KindPropertyAccessExpression, ast.KindParenthesizedExpression, ast.KindNonNullExpression:
2638 return isNarrowableReference(node.Expression())
2639 case ast.KindElementAccessExpression:
2640 expr := node.AsElementAccessExpression()
2641 return ast.IsStringOrNumericLiteralLike(expr.ArgumentExpression) ||
2642 ast.IsEntityNameExpression(expr.ArgumentExpression) && isNarrowableReference(expr.Expression)
2643 case ast.KindBinaryExpression:
2644 expr := node.AsBinaryExpression()
2645 return expr.OperatorToken.Kind == ast.KindCommaToken && isNarrowableReference(expr.Right) ||
2646 ast.IsAssignmentOperator(expr.OperatorToken.Kind) && ast.IsLeftHandSideExpression(expr.Left)
2647 }
2648 return false
2649}
2650
2651func hasNarrowableArgument(expr *ast.Node) bool {
2652 call := expr.AsCallExpression()

Callers 3

bindMethod · 0.85

Calls 7

IsEntityNameExpressionFunction · 0.92
IsAssignmentOperatorFunction · 0.92
IsLeftHandSideExpressionFunction · 0.92
ExpressionMethod · 0.80
AsBinaryExpressionMethod · 0.80

Tested by

no test coverage detected