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

Function namespaceDeclaringFile

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

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