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

Function resolveFromOwnConfig

src/resolution/import-resolver.ts:1656–1678  ·  view source on GitHub ↗

* A bare specifier `isExternalImport` takes for a package, resolved through * the importing app's own tsconfig / jsconfig — the one nearest the file, * else the root's — as tsc and a paths-aware bundler resolve it: the most * specific `paths` pattern it matches (a catch-all `"*": ["./src/*"]`, an

(
  importPath: string,
  fromFile: string,
  language: Language,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

1654 * `typings/legacy-widgets.d.ts`.
1655 */
1656function resolveFromOwnConfig(
1657 importPath: string,
1658 fromFile: string,
1659 language: Language,
1660 context: ResolutionContext
1661): string | null {
1662 const candidates = ownConfigCandidates(importPath, fromFile, language, context);
1663 if (!candidates) return null;
1664 const indexed = (file: string): boolean => context.isIndexedFile?.(file) !== false;
1665 if (context.isDeclaredPackage?.(importPath, fromFile) !== false) {
1666 if (!EXTENSION_RESOLUTION[language]?.includes('.d.ts')) return null;
1667 for (const candidate of candidates) {
1668 const declarations = `${candidate}.d.ts`;
1669 if (context.fileExists(declarations) && indexed(declarations)) return declarations;
1670 }
1671 return null;
1672 }
1673 for (const candidate of candidates) {
1674 const hit = tryWithExtensions(candidate, language, context);
1675 if (hit && indexed(hit)) return hit;
1676 }
1677 return null;
1678}
1679
1680/**
1681 * Where the importing app's own config reads a bare specifier from (see

Callers 1

Calls 5

ownConfigCandidatesFunction · 0.85
tryWithExtensionsFunction · 0.85
isDeclaredPackageMethod · 0.80
fileExistsMethod · 0.80
indexedFunction · 0.70

Tested by

no test coverage detected