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

Function getTypeOfNode

test/fixtures/snapshot/typescript.js:86557–86615  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

86555 }
86556 }
86557 function getTypeOfNode(node) {
86558 if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
86559 return errorType;
86560 }
86561 if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
86562 // We cannot answer semantic questions within a with block, do not proceed any further
86563 return errorType;
86564 }
86565 var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
86566 var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
86567 if (ts.isPartOfTypeNode(node)) {
86568 var typeFromTypeNode = getTypeFromTypeNode(node);
86569 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
86570 }
86571 if (ts.isExpressionNode(node)) {
86572 return getRegularTypeOfExpression(node);
86573 }
86574 if (classType && !classDecl.isImplements) {
86575 // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
86576 // extends clause of a class. We handle that case here.
86577 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
86578 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
86579 }
86580 if (isTypeDeclaration(node)) {
86581 // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
86582 var symbol = getSymbolOfNode(node);
86583 return getDeclaredTypeOfSymbol(symbol);
86584 }
86585 if (isTypeDeclarationName(node)) {
86586 var symbol = getSymbolAtLocation(node);
86587 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
86588 }
86589 if (ts.isDeclaration(node)) {
86590 // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
86591 var symbol = getSymbolOfNode(node);
86592 return symbol ? getTypeOfSymbol(symbol) : errorType;
86593 }
86594 if (isDeclarationNameOrImportPropertyName(node)) {
86595 var symbol = getSymbolAtLocation(node);
86596 if (symbol) {
86597 return getTypeOfSymbol(symbol);
86598 }
86599 return errorType;
86600 }
86601 if (ts.isBindingPattern(node)) {
86602 return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType;
86603 }
86604 if (isInRightSideOfImportOrExportAssignment(node)) {
86605 var symbol = getSymbolAtLocation(node);
86606 if (symbol) {
86607 var declaredType = getDeclaredTypeOfSymbol(symbol);
86608 return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
86609 }
86610 }
86611 if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
86612 return checkMetaPropertyKeyword(node.parent);
86613 }
86614 return errorType;

Calls 15

getSymbolOfNodeFunction · 0.85
getTypeFromTypeNodeFunction · 0.85
getTypeWithThisArgumentFunction · 0.85
getBaseTypesFunction · 0.85
isTypeDeclarationFunction · 0.85
getDeclaredTypeOfSymbolFunction · 0.85
isTypeDeclarationNameFunction · 0.85
getSymbolAtLocationFunction · 0.85
getTypeOfSymbolFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…