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

Function namespaceDeclaringFile

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

3159
3160/** The file that declares the namespace a module exports as `name`, through its re-exports, and the name it declares it under. */
3161function namespaceDeclaringFile(
3162 file: string,
3163 name: string,
3164 language: Language,
3165 context: ResolutionContext,
3166 depth = 0,
3167): { file: string; name: string } | undefined {
3168 if (depth > REEXPORT_MAX_DEPTH) return undefined;
3169 if (namespaceBlocks(file, context).some((b) => b.path === name || b.path.startsWith(`${name}.`))) return { file, name };
3170 for (const rex of context.getReExports?.(file, language) ?? []) {
3171 if (rex.kind !== 'wildcard' && !(rex.kind === 'named' && rex.exportedName === name)) continue;
3172 const next = resolveImportPath(rex.source, file, language, context);
3173 const found = next ? namespaceDeclaringFile(next, rex.kind === 'named' ? rex.originalName : name, language, context, depth + 1) : undefined;
3174 if (found) return found;
3175 }
3176 return undefined;
3177}
3178
3179export function resolveViaImport(
3180 ref: UnresolvedRef,

Callers 1

importedTypeMemberFunction · 0.85

Calls 3

namespaceBlocksFunction · 0.90
resolveImportPathFunction · 0.85
getReExportsMethod · 0.80

Tested by

no test coverage detected