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

Function calculateUsageOfNode

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

Source from the content-addressed store, hash-verified

157013 return inferTypes(usage);
157014 }
157015 function calculateUsageOfNode(node, usage) {
157016 while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {
157017 node = node.parent;
157018 }
157019 switch (node.parent.kind) {
157020 case 238 /* SyntaxKind.ExpressionStatement */:
157021 inferTypeFromExpressionStatement(node, usage);
157022 break;
157023 case 220 /* SyntaxKind.PostfixUnaryExpression */:
157024 usage.isNumber = true;
157025 break;
157026 case 219 /* SyntaxKind.PrefixUnaryExpression */:
157027 inferTypeFromPrefixUnaryExpression(node.parent, usage);
157028 break;
157029 case 221 /* SyntaxKind.BinaryExpression */:
157030 inferTypeFromBinaryExpression(node, node.parent, usage);
157031 break;
157032 case 289 /* SyntaxKind.CaseClause */:
157033 case 290 /* SyntaxKind.DefaultClause */:
157034 inferTypeFromSwitchStatementLabel(node.parent, usage);
157035 break;
157036 case 208 /* SyntaxKind.CallExpression */:
157037 case 209 /* SyntaxKind.NewExpression */:
157038 if (node.parent.expression === node) {
157039 inferTypeFromCallExpression(node.parent, usage);
157040 }
157041 else {
157042 inferTypeFromContextualType(node, usage);
157043 }
157044 break;
157045 case 206 /* SyntaxKind.PropertyAccessExpression */:
157046 inferTypeFromPropertyAccessExpression(node.parent, usage);
157047 break;
157048 case 207 /* SyntaxKind.ElementAccessExpression */:
157049 inferTypeFromPropertyElementExpression(node.parent, node, usage);
157050 break;
157051 case 296 /* SyntaxKind.PropertyAssignment */:
157052 case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
157053 inferTypeFromPropertyAssignment(node.parent, usage);
157054 break;
157055 case 167 /* SyntaxKind.PropertyDeclaration */:
157056 inferTypeFromPropertyDeclaration(node.parent, usage);
157057 break;
157058 case 254 /* SyntaxKind.VariableDeclaration */: {
157059 var _a = node.parent, name = _a.name, initializer = _a.initializer;
157060 if (node === name) {
157061 if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error.
157062 addCandidateType(usage, checker.getTypeAtLocation(initializer));
157063 }
157064 break;
157065 }
157066 }
157067 // falls through
157068 default:
157069 return inferTypeFromContextualType(node, usage);
157070 }
157071 }
157072 function inferTypeFromContextualType(node, usage) {

Callers 6

parametersFunction · 0.85
thisParameterFunction · 0.85

Tested by

no test coverage detected