Files
codegraph/__tests__
Eric MinishandClaude Opus 5.5 59eb0d2820 fix(resolution): an import no longer lands on a same-named method of an exported object
An exported object literal's methods (`export const d = { f() {} }`) are
indexed as exported nodes named `f` (qualified name `d::f`), and the
per-file export index kept the first exported node per name. So
`import { f } from './m'` could link to `d.f` instead of the module's own
`export function f`, and which one won depended only on declaration order.

A JS/TS member, a node whose qualified name differs from its name, now
ranks behind the module's own bindings wherever an import is matched to an
export: a named import (the module's own `f`, then its export clause, then
its re-exports, then a member), an export clause's local name,
`export default f` and `module.exports = f`. A member is never dropped:
`export const { f } = d` binds `f` with no node of its own, and `d::f` is
its only answer. The default-import guess no longer picks a member.

Validation on main de0a4eb3 (Windows 11):
- Red/green: 7 of the 13 new tests fail with main's import-resolver.ts;
  all 13 pass with the fix, with the kernel and with CODEGRAPH_KERNEL=0.
- A/B against main: express, vuejs/core and excalidraw are byte-identical,
  as are the flask and gin controls. codegraph's own source retargets 195
  sites, each from a `hashNavigation` method to the exported function of
  the same name in ui/src/lib/navigation.ts, the issue's case. vscode's
  base and editor retarget 328 sites: 321 imports and calls of `join`,
  `basename`, `dirname` and 5 other path functions move from the `win32`
  object's methods to path.ts's own exports
  (`export const join = (platformIsWin32 ? win32.join : posix.join)`), and
  7 `marked.lexer` and `marked.parse` calls move from a `_Tokenizer` field
  and a `_Parser` static method to the `lexer` and `parse` that marked.js
  exports. No edge is added or removed.
- Index time unchanged: median of 3 interleaved runs on vscode's base and
  editor, 16.6 s on main and 17.2 s with the fix.

Original PR #2990 by @inth3shadows.
Fixes #2945

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:20:22 +00:00
..