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

Function findSourceForEmittedSpecifier

src/resolution/import-resolver.ts:1477–1494  ·  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

1475];
1476
1477function findSourceForEmittedSpecifier(
1478 relativePath: string,
1479 language: Language,
1480 context: ResolutionContext,
1481 exists: (file: string) => boolean = (file) => context.fileExists(file)
1482): string | null {
1483 if (!EMITTED_SPECIFIER_LANGUAGES.has(language)) return null;
1484 for (const [emitted, sources] of EMITTED_TO_SOURCE_EXTENSIONS) {
1485 if (!emitted.test(relativePath)) continue;
1486 const stem = relativePath.replace(emitted, '');
1487 for (const ext of sources) {
1488 const candidate = stem + ext;
1489 if (exists(candidate)) return candidate;
1490 }
1491 return null;
1492 }
1493 return null;
1494}
1495
1496/** Languages whose import specifiers can name the emitted `.js` of a `.ts` source. */
1497const 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