Repository navigation
fix(symbols): refs find inline type imports, re-exported imports, and split type/value names - #486
Merged
Merged
Conversation
…t type and value names
- `import("./m").Row` in a type names Row through the module and export
resolver, barrels included; `typeof import("./m").v` names the value.
- `import { A } from "./a"; export { A }` resolves to ./a, so callers through
that module reach the declaration (symbol index and import graph).
- A type-only and a value-only declaration of one name are two symbols: the
value keeps `file#A`, the type is `file#A@type`, and each reference
resolves in the namespace its position uses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bility apart
Round 1 review fixes:
- `x as import("./m").T` and `satisfies` name the type; a class's
`extends ns.A` names the value; a receiver from `new A()` is the value A.
- Generic parameters (`<Row>`) bind their own name, never an outer type.
- Destructured top-level names are declarations, so a re-export of one stays local.
- A split name is public per namespace; inline imports need a public export.
- The client keeps `@type` in Show references and drops it to find the code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e instance
Round 2 review fixes:
- `import("./m").X` names the type X wherever tree-sitter puts it (call type
arguments, `keyof`, error nodes), except the promise's then/catch/finally.
- `x: A` with `type A = InstanceType<typeof A>` settles members on the value A.
- A `type A` in a nearer block wins over an outer generic `<A>`.
- Open code on a split type lands on its line; Show references in the code
viewer picks the declaration on the clicked line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 3 finding: `x: A` with the split `type A = B` settled `x.run()` on the value A. The alias now records its class (`type A = B` is B, `InstanceType<typeof A>` is the value A), and the call follows that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
byronwall
force-pushed
the
claude/symbol-ref-gaps
branch
from
November 28, 2026 05:05
1bab538 to
c7c3b6d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
srcly refsand the Symbols view missed callers in three TypeScript cases. An agent that maps callers before it deletes a type could leave one of these callers behind. Now all three resolve to the declaration that TypeScript binds.Before:
import("@/types/AnalysisProject").AnalysisSourceRowin a type gave no reference.import { A } …; export { A }) lost every caller that imported A through it.export const EvidenceCollector = …andexport type EvidenceCollector = …were one symbol, so a type use and a value use were the same reference.After:
import type, barrels included.typeof import(…).vnames the value.file#A, so the Imports graph,atand existing links do not change. The type isfile#A@type. Each reference picks the side its position uses. A class or enum merged with an interface stays one symbol. In the client, Show references keeps@type, and Open code goes to the type's line.Cause
The extractor resolved names only through static import bindings and one shared name table per file.
find_definerstopped at a local export, even when that export named an import.Proof
srcly refson the three cases. Before isclaude/duplicate-type; after is this branch. explorEDA is atf44a5c63.All references of every symbol in both repos, before and after (each
(source, target, kind, line, resolution)row ofbuild_symbol_index):analysisWorker.ts:9. The other 22 are callers through a module that imports and exports a name again:ForeignKey(8),ChartExportError(4),SavedDataStructure(4),ExplorEdaSidePanel(3),DatePreset(2) andfocusChartInContainer(1).ProgramEvidenceCollector, which now starts fromEvidenceCollector@type.build_ts_edges): explorEDA has 14,154 → 14,156 edges (+18, −16). File-level edges to the re-exporting module become symbol edges to the defining file. srcly has 8,477 → 8,484 (+22, −15). Destructured exports such asexport const [location, setLocation] = …now count as declarations, so their importers get symbol-level edges (for exampleApp.tsx#AppContent → navigation/store.ts#location).Tests:
server/tests/test_symbol_index_ts.pyadds one test per gap. They cover the inline import, the import then export again, and the type/value split. Each also holds the review's regression cases, and the cases fail on the commits before each fix.scripts/check.sh serverpasses (649 tests). Clientpnpm typecheckpasses, andsrc/navigation+src/symbolsvitest passes (53 tests).Survey moves: corpus edits only, with no analysis change. This PR edits
server/app/services/symbols/typescript.py,index.py,deps/typescript_deps.pyand the client filesApp.tsx,CodeModal.tsx,navigation/location.tsandsymbols/contract.ts. The sample now traces the new_in_typeofand_type_parameter_bound(both assumed). Server: traces +3, assumed +2, partial +1, external-code stops +44. Client: budget-exhausted stops +1.Review
Codex reviewed three rounds (
gpt-6.2-sol). Round 3 ended with no P0 and 3 P1s.asandsatisfiestypes.extends ns.Anow names the value.new A()receiver.@type.import(…).Xis a type wherever tree-sitter puts it, except a promise'sthen,catchorfinally.type A = Bgives B,InstanceType<typeof A>gives the value A), never a same-name value. The test istest_type_and_value_of_one_name_are_two_symbols.srcly refs, the Imports graph and the Symbols view from the data-flow engine's TypeScript checker, resolve editor and treemap actions by source position, and leave unbound references unresolved. Most open findings below are tree-sitter edge cases that this change would remove.Limits
keyof import(…).Rowbreaks tree-sitter's parse of the alias, so the reference comes from the file's module node, not the alias. It is still listed as a caller.Open findings
pick<typeof import("./m").Row>()parsestypeofas an expression, so a split name resolves toRow@type, not the value. An exported type namedthen,catchorfinallyis skipped. JSX type arguments<C<import("./m").Row> />are missed. Open: needs a parse that keeps type positions (the checker, per the architecture note).T, declares a local valueTand exports{ T }sends type and value users to the local value. Open: needs separate type and value targets for each export hop.outer<Row>()attaches to the module'sRow. Open: block-local types are not predeclared.export default function Aandexport type A, a default import used as a type binds toA@type, andtypeof import("./m").Abinds to the default function. Open: visibility is not checked per public name.Stack: srcly cleanup helpers, layer 4 of 4
This slice: Fixes three TypeScript symbol-index gaps, so
srcly refs(#482) lists every caller.Why it is its own layer: It changes the core symbol index, not the CLI, and needs its own review. It does not depend on #483 or #485. It sits on top because a stack is linear.
Full story: #482
🤖 Generated with Claude Code