Skip to content

[Bug]: TypeScript calls through optional typed dependencies are missing from the graph #5654

Backlog

Description

@rvitaliy

On v0.9.124 (d249de367), a typed route factory can call an optional dependency through ?., but Graphify drops the call even when the imported declarations identify one method. A required dependency with the same type produces an inferred call. This makes reverse navigation from the method miss real callers.

Reproduce

Save these three TypeScript files in an empty directory.

// ports.ts
export interface Reader {
  read(): number;
}

export interface Store {
  get(): number;
}

export interface OtherStore {
  get(): string;
}

// deps.ts
import type { OtherStore, Reader, Store } from './ports.js';

export type Dependencies = Readonly<{
  required: Reader;
  reader?: Reader;
  reads?: Readonly<{ store: Store }>;
  unrelated?: Readonly<{ store: OtherStore }>;
}>;

// routes.ts
import type { Dependencies } from './deps.js';

export function required(deps: Pick<Dependencies, 'required'>) {
  return deps.required.read();
}

export function read(deps: Pick<Dependencies, 'reader'>) {
  return deps.reader?.read();
}

export function load(deps: Pick<Dependencies, 'reads'>) {
  return deps.reads?.store.get();
}

Run graphify extract . --code-only --no-cluster and inspect the calls edges originating in routes.ts in graphify-out/graph.json.

Caller Actual Expected target
required Reader.read Reader.read
read No edge Reader.read
load No edge Store.get

Both missing edges should be inferred and carry the call-site location. The optional chain can skip the call at runtime. If the call executes, the receiver type is known. The unrelated OtherStore.get in the same project must remain distinct.

Reproduced from a clean graph on macOS arm64 with CPython 3.14.6. This extends the direct property resolution from #5586 to optional chaining at the corresponding property hop.

Activity

  1. github-actions commented on Nov 30, 2026

    @github-actions

    Thanks for opening this issue, @rvitaliy. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions