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

Function getTypeFromTypeReference

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

Source from the content-addressed store, hash-verified

60570 return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type;
60571 }
60572 function getTypeFromTypeReference(node) {
60573 var links = getNodeLinks(node);
60574 if (!links.resolvedType) {
60575 // handle LS queries on the `const` in `x as const` by resolving to the type of `x`
60576 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
60577 links.resolvedSymbol = unknownSymbol;
60578 return links.resolvedType = checkExpressionCached(node.parent.expression);
60579 }
60580 var symbol = void 0;
60581 var type = void 0;
60582 var meaning = 788968 /* SymbolFlags.Type */;
60583 if (isJSDocTypeReference(node)) {
60584 type = getIntendedTypeFromJSDocTypeReference(node);
60585 if (!type) {
60586 symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
60587 if (symbol === unknownSymbol) {
60588 symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */);
60589 }
60590 else {
60591 resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
60592 }
60593 type = getTypeReferenceType(node, symbol);
60594 }
60595 }
60596 if (!type) {
60597 symbol = resolveTypeReferenceName(node, meaning);
60598 type = getTypeReferenceType(node, symbol);
60599 }
60600 // Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
60601 // type reference in checkTypeReferenceNode.
60602 links.resolvedSymbol = symbol;
60603 links.resolvedType = type;
60604 }
60605 return links.resolvedType;
60606 }
60607 function typeArgumentsFromTypeReferenceNode(node) {
60608 return ts.map(node.typeArguments, getTypeFromTypeNode);
60609 }

Callers 4

checkTypeReferenceNodeFunction · 0.85
visitFunction · 0.85

Calls 6

getNodeLinksFunction · 0.85
checkExpressionCachedFunction · 0.85
isJSDocTypeReferenceFunction · 0.85
resolveTypeReferenceNameFunction · 0.85
getTypeReferenceTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…