(expr *ast.Node)
| 2600 | } |
| 2601 | |
| 2602 | func isNarrowingExpression(expr *ast.Node) bool { |
| 2603 | switch expr.Kind { |
| 2604 | case ast.KindIdentifier, ast.KindThisKeyword: |
| 2605 | return true |
| 2606 | case ast.KindPropertyAccessExpression, ast.KindElementAccessExpression: |
| 2607 | return containsNarrowableReference(expr) |
| 2608 | case ast.KindCallExpression: |
| 2609 | return hasNarrowableArgument(expr) |
| 2610 | case ast.KindParenthesizedExpression, ast.KindNonNullExpression, ast.KindTypeOfExpression: |
| 2611 | return isNarrowingExpression(expr.Expression()) |
| 2612 | case ast.KindBinaryExpression: |
| 2613 | return isNarrowingBinaryExpression(expr.AsBinaryExpression()) |
| 2614 | case ast.KindPrefixUnaryExpression: |
| 2615 | return expr.AsPrefixUnaryExpression().Operator == ast.KindExclamationToken && isNarrowingExpression(expr.AsPrefixUnaryExpression().Operand) |
| 2616 | } |
| 2617 | return false |
| 2618 | } |
| 2619 | |
| 2620 | func containsNarrowableReference(expr *ast.Node) bool { |
| 2621 | if isNarrowableReference(expr) { |
no test coverage detected