MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / findSourceForEmittedSpecifier

Function findSourceForEmittedSpecifier

src/resolution/import-resolver.ts:1416–1433  ·  view source on GitHub ↗
(
  relativePath: string,
  language: Language,
  context: ResolutionContext,
  exists: (file: string) => boolean = (file) => context.fileExists(file)
)

Source from the content-addressed store, hash-verified

1414];
1415
1416function findSourceForEmittedSpecifier(
1417 relativePath: string,
1418 language: Language,
1419 context: ResolutionContext,
1420 exists: (file: string) => boolean = (file) => context.fileExists(file)
1421): string | null {
1422 if (!EMITTED_SPECIFIER_LANGUAGES.has(language)) return null;
1423 for (const [emitted, sources] of EMITTED_TO_SOURCE_EXTENSIONS) {
1424 if (!emitted.test(relativePath)) continue;
1425 const stem = relativePath.replace(emitted, '');
1426 for (const ext of sources) {
1427 const candidate = stem + ext;
1428 if (exists(candidate)) return candidate;
1429 }
1430 return null;
1431 }
1432 return null;
1433}
1434
1435/** Languages whose import specifiers can name the emitted `.js` of a `.ts` source. */
1436const EMITTED_SPECIFIER_LANGUAGES: ReadonlySet<string> = new Set([

Callers 3

resolveRelativeImportFunction · 0.85
tryWithExtensionsFunction · 0.85
indexedTargetFunction · 0.85

Calls 3

fileExistsMethod · 0.80
hasMethod · 0.80
existsFunction · 0.50

Tested by

no test coverage detected