MCPcopy Index your code
hub / github.com/nodejs/node / inferTypeFromBinaryExpression

Function inferTypeFromBinaryExpression

test/fixtures/snapshot/typescript.js:157095–157192  ·  view source on GitHub ↗
(node, parent, usage)

Source from the content-addressed store, hash-verified

157093 }
157094 }
157095 function inferTypeFromBinaryExpression(node, parent, usage) {
157096 switch (parent.operatorToken.kind) {
157097 // ExponentiationOperator
157098 case 42 /* SyntaxKind.AsteriskAsteriskToken */:
157099 // MultiplicativeOperator
157100 // falls through
157101 case 41 /* SyntaxKind.AsteriskToken */:
157102 case 43 /* SyntaxKind.SlashToken */:
157103 case 44 /* SyntaxKind.PercentToken */:
157104 // ShiftOperator
157105 // falls through
157106 case 47 /* SyntaxKind.LessThanLessThanToken */:
157107 case 48 /* SyntaxKind.GreaterThanGreaterThanToken */:
157108 case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */:
157109 // BitwiseOperator
157110 // falls through
157111 case 50 /* SyntaxKind.AmpersandToken */:
157112 case 51 /* SyntaxKind.BarToken */:
157113 case 52 /* SyntaxKind.CaretToken */:
157114 // CompoundAssignmentOperator
157115 // falls through
157116 case 65 /* SyntaxKind.MinusEqualsToken */:
157117 case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */:
157118 case 66 /* SyntaxKind.AsteriskEqualsToken */:
157119 case 68 /* SyntaxKind.SlashEqualsToken */:
157120 case 69 /* SyntaxKind.PercentEqualsToken */:
157121 case 73 /* SyntaxKind.AmpersandEqualsToken */:
157122 case 74 /* SyntaxKind.BarEqualsToken */:
157123 case 78 /* SyntaxKind.CaretEqualsToken */:
157124 case 70 /* SyntaxKind.LessThanLessThanEqualsToken */:
157125 case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */:
157126 case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */:
157127 // AdditiveOperator
157128 // falls through
157129 case 40 /* SyntaxKind.MinusToken */:
157130 // RelationalOperator
157131 // falls through
157132 case 29 /* SyntaxKind.LessThanToken */:
157133 case 32 /* SyntaxKind.LessThanEqualsToken */:
157134 case 31 /* SyntaxKind.GreaterThanToken */:
157135 case 33 /* SyntaxKind.GreaterThanEqualsToken */:
157136 var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
157137 if (operandType.flags & 1056 /* TypeFlags.EnumLike */) {
157138 addCandidateType(usage, operandType);
157139 }
157140 else {
157141 usage.isNumber = true;
157142 }
157143 break;
157144 case 64 /* SyntaxKind.PlusEqualsToken */:
157145 case 39 /* SyntaxKind.PlusToken */:
157146 var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left);
157147 if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) {
157148 addCandidateType(usage, otherOperandType);
157149 }
157150 else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) {
157151 usage.isNumber = true;
157152 }

Callers 1

calculateUsageOfNodeFunction · 0.85

Calls 1

addCandidateTypeFunction · 0.85

Tested by

no test coverage detected