MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getTypeFromTypeReference

Method getTypeFromTypeReference

internal/checker/checker.go:22909–22924  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

22907}
22908
22909func (c *Checker) getTypeFromTypeReference(node *ast.Node) *Type {
22910 links := c.typeNodeLinks.Get(node)
22911 if links.resolvedType == nil {
22912 // Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
22913 // type reference in checkTypeReferenceNode.
22914 // handle LS queries on the `const` in `x as const` by resolving to the type of `x`
22915 if isConstTypeReference(node) && ast.IsAssertionExpression(node.Parent) {
22916 links.resolvedType = c.checkExpressionCached(node.Parent.Expression())
22917 } else if t := c.getIntendedTypeFromJSDocTypeReference(node); t != nil {
22918 links.resolvedType = t
22919 } else {
22920 links.resolvedType = c.getTypeReferenceType(node, c.getSymbolFromTypeReference(node))
22921 }
22922 }
22923 return links.resolvedType
22924}
22925
22926func (c *Checker) getIntendedTypeFromJSDocTypeReference(node *ast.Node) *Type {
22927 if node.Flags&ast.NodeFlagsJSDoc != 0 && ast.IsTypeReferenceNode(node) {

Calls 8

checkExpressionCachedMethod · 0.95
getTypeReferenceTypeMethod · 0.95
IsAssertionExpressionFunction · 0.92
isConstTypeReferenceFunction · 0.85
ExpressionMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected