MCPcopy Create free account
hub / github.com/nodejs/node / isNarrowingExpression

Function isNarrowingExpression

test/fixtures/snapshot/typescript.js:45339–45360  ·  view source on GitHub ↗
(expr)

Source from the content-addressed store, hash-verified

45337 inAssignmentPattern = saveInAssignmentPattern;
45338 }
45339 function isNarrowingExpression(expr) {
45340 switch (expr.kind) {
45341 case 79 /* SyntaxKind.Identifier */:
45342 case 80 /* SyntaxKind.PrivateIdentifier */:
45343 case 108 /* SyntaxKind.ThisKeyword */:
45344 case 206 /* SyntaxKind.PropertyAccessExpression */:
45345 case 207 /* SyntaxKind.ElementAccessExpression */:
45346 return containsNarrowableReference(expr);
45347 case 208 /* SyntaxKind.CallExpression */:
45348 return hasNarrowableArgument(expr);
45349 case 212 /* SyntaxKind.ParenthesizedExpression */:
45350 case 230 /* SyntaxKind.NonNullExpression */:
45351 return isNarrowingExpression(expr.expression);
45352 case 221 /* SyntaxKind.BinaryExpression */:
45353 return isNarrowingBinaryExpression(expr);
45354 case 219 /* SyntaxKind.PrefixUnaryExpression */:
45355 return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand);
45356 case 216 /* SyntaxKind.TypeOfExpression */:
45357 return isNarrowingExpression(expr.expression);
45358 }
45359 return false;
45360 }
45361 function isNarrowableReference(expr) {
45362 return ts.isDottedName(expr)
45363 || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)

Callers 3

createFlowConditionFunction · 0.85
bindCaseBlockFunction · 0.85

Calls 3

hasNarrowableArgumentFunction · 0.85

Tested by

no test coverage detected