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

Function findSourceForEmittedSpecifier

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

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