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

Function resolveFromOwnConfig

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

1963 * `typings/legacy-widgets.d.ts`.
1964 */
1965function resolveFromOwnConfig(
1966 importPath: string,
1967 fromFile: string,
1968 language: Language,
1969 context: ResolutionContext
1970): string | null {
1971 const candidates = ownConfigCandidates(importPath, fromFile, language, context);
1972 if (!candidates) return null;
1973 const indexed = (file: string): boolean => context.isIndexedFile?.(file) !== false;
1974 if (context.isDeclaredPackage?.(importPath, fromFile) !== false) {
1975 if (!EXTENSION_RESOLUTION[language]?.includes('.d.ts')) return null;
1976 for (const candidate of candidates) {
1977 const declarations = `${candidate}.d.ts`;
1978 if (context.fileExists(declarations) && indexed(declarations)) return declarations;
1979 }
1980 return null;
1981 }
1982 for (const candidate of candidates) {
1983 const hit = tryWithExtensions(candidate, language, context);
1984 if (hit && indexed(hit)) return hit;
1985 }
1986 return null;
1987}
1988
1989/**
1990 * 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