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

Function namespaceDeclaringFile

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

The file that declares the namespace a module exports as `name`, through its re-exports, and the name it declares it under.

(
  file: string,
  name: string,
  language: Language,
  context: ResolutionContext,
  depth = 0,
)

Source from the content-addressed store, hash-verified

3260
3261/** The file that declares the namespace a module exports as `name`, through its re-exports, and the name it declares it under. */
3262function namespaceDeclaringFile(
3263 file: string,
3264 name: string,
3265 language: Language,
3266 context: ResolutionContext,
3267 depth = 0,
3268): { file: string; name: string } | undefined {
3269 if (depth > REEXPORT_MAX_DEPTH) return undefined;
3270 if (namespaceBlocks(file, context).some((b) => b.path === name || b.path.startsWith(`${name}.`))) return { file, name };
3271 for (const rex of context.getReExports?.(file, language) ?? []) {
3272 if (rex.kind !== 'wildcard' && !(rex.kind === 'named' && rex.exportedName === name)) continue;
3273 const next = resolveImportPath(rex.source, file, language, context);
3274 const found = next ? namespaceDeclaringFile(next, rex.kind === 'named' ? rex.originalName : name, language, context, depth + 1) : undefined;
3275 if (found) return found;
3276 }
3277 return undefined;
3278}
3279
3280/**
3281 * The module whose namespace object `file` exports as `name`, when that

Callers 1

importedTypeMemberFunction · 0.85

Calls 3

namespaceBlocksFunction · 0.90
resolveImportPathFunction · 0.85
getReExportsMethod · 0.80

Tested by

no test coverage detected