Skip to content

TypeScript: calls through a renamed named import (import { foo as bar }) produce no CALLS edge #2297

Open

Description

@huyiacisla

Summary

trace_path (inbound) misses callers that invoke a function through a renamed named import.
Plain named imports and namespace imports resolve correctly, so the gap is specific to the as alias.

Minimal repro (4 files, relative imports only)

// src/lib.ts
export function foo(x: number): number {
  return x + 1;
}

// src/plain.ts
import { foo } from "./lib";
export function callsPlain(): number {
  return foo(1);
}

// src/renamed.ts
import { foo as fooShared } from "./lib";
export function callsRenamed(): number {
  return fooShared(1);
}

// src/namespace.ts
import * as lib from "./lib";
export function callsNamespace(): number {
  return lib.foo(1);
}
index_repository(repo_path=<repro>, mode="fast")   # 15 nodes, 19 edges, 0 skipped/partial
trace_path(function_name="foo", direction="inbound", depth=1, include_evidence=true)

Actual

callers_total: 2
  src.namespace.callsNamespace  1  lsp  0.95
  src.plain.callsPlain          1  lsp  0.95

Expected

src.renamed.callsRenamed listed as a caller too (3 callers).

Real-world impact

In a pnpm TypeScript monorepo (≈2.8k source files, index_mode full), 37 value imports in 19 files use
import { X as Y } from "@scope/pkg". A common pattern is an app-local wrapper that binds an app-specific argument:

import { buildOperationalHealth as buildShared } from "@scope/shared/operational-health";
export function buildOperationalHealth(input) {
  return buildShared({ ...input, hostScope: "admin" });
}

trace_path on the shared function reports 2 of 4 real hop-1 callers, and every caller of the wrappers
is lost for multi-hop queries.

Environment

Activity

  1. DeusData commented on Oct 19, 2026

    @DeusData
    Owner

    Thank you for the plain, namespace, and renamed import controls. They make the alias-specific missing caller clear without conflating it with re-export aliases. I have added the bug classification; the resolution still needs verification.

  2. DeusData commented on Oct 25, 2026

    @DeusData
    Owner

    Thank you for the controlled import-alias example. The missing caller through the renamed import still needs maintainer verification. Sorry for the delay; I’ll follow up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edges

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions