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

Function resolveFromOwnConfig

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

1715 * `typings/legacy-widgets.d.ts`.
1716 */
1717function resolveFromOwnConfig(
1718 importPath: string,
1719 fromFile: string,
1720 language: Language,
1721 context: ResolutionContext
1722): string | null {
1723 const candidates = ownConfigCandidates(importPath, fromFile, language, context);
1724 if (!candidates) return null;
1725 const indexed = (file: string): boolean => context.isIndexedFile?.(file) !== false;
1726 if (context.isDeclaredPackage?.(importPath, fromFile) !== false) {
1727 if (!EXTENSION_RESOLUTION[language]?.includes('.d.ts')) return null;
1728 for (const candidate of candidates) {
1729 const declarations = `${candidate}.d.ts`;
1730 if (context.fileExists(declarations) && indexed(declarations)) return declarations;
1731 }
1732 return null;
1733 }
1734 for (const candidate of candidates) {
1735 const hit = tryWithExtensions(candidate, language, context);
1736 if (hit && indexed(hit)) return hit;
1737 }
1738 return null;
1739}
1740
1741/**
1742 * 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