MCPcopy Create free account
hub / github.com/Snapchat/Valdi / resolveTypeReference

Function resolveTypeReference

compiler/companion/src/AST.ts:224–250  ·  view source on GitHub ↗
(
  type: ts.NodeWithTypeArguments,
  resolvedSymbol: ResolvedSymbol,
  references: AST.TypeReferences,
)

Source from the content-addressed store, hash-verified

222}
223
224function resolveTypeReference(
225 type: ts.NodeWithTypeArguments,
226 resolvedSymbol: ResolvedSymbol,
227 references: AST.TypeReferences,
228): number {
229 if (!resolvedSymbol.sourceFile) {
230 throw new Error(`No declarations for resolve symbol ${getNodeDebugDescription(type)}`);
231 }
232
233 const symbolName = resolvedSymbol.name;
234 const sourceFile = resolvedSymbol.sourceFile;
235 const sourceFileLocation = sourceFile.fileName;
236
237 const typeReferences = references.references;
238
239 for (let i = 0; i < typeReferences.length; i++) {
240 const existingReference = typeReferences[i];
241 if (existingReference.name === symbolName && existingReference.fileName === sourceFileLocation) {
242 return i;
243 }
244 }
245
246 const index = typeReferences.length;
247 typeReferences.push({ name: symbolName, fileName: sourceFileLocation });
248
249 return index;
250}
251
252function parseTypeFromSymbolGroup(
253 type: ts.NodeWithTypeArguments,

Callers 1

parseTypeFromSymbolGroupFunction · 0.85

Calls 2

getNodeDebugDescriptionFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected