Fix references code lens to include imports as references - #2368
Closed
Jake Bailey (jakebailey) with Copilot wants to merge 4 commits into
Closed
Fix references code lens to include imports as references#2368Jake Bailey (jakebailey) with Copilot wants to merge 4 commits into
Jake Bailey (jakebailey) with Copilot wants to merge 4 commits into
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
When finding references for an exported symbol, the import specifier
(e.g., `abc` in `import { abc } from "./abc"`) should be counted as
a reference to the export. This change:
1. Adds the import location as a reference to the export symbol in
searchForImportsOfExport for non-aliased imports.
2. Skips duplicate addition of import specifiers when the search
is coming from an export context, since they're already added
by the explicit addRef call.
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Jake Bailey (jakebailey)
left a comment
Member
There was a problem hiding this comment.
Copilot whatever you add, make sure it actually has a basis in the original implementation, and not something made up
| // === findAllReferences === | ||
| // === /myproject/a/index.ts === | ||
| // import { [|B|] } from "../b/lib"; | ||
| // import { [|[|B|]|] } from "../b/lib"; |
Comment on lines
+6
to
+8
| -// import { Interface } from "./def"; | ||
| -// const c: I/*GOTO IMPL*/nterface = [|{ P: 2 }|]; | ||
| +// <|import { [|Interface|] } from "./def";|> |
Copilot
AI
changed the title
[WIP] Add fourslash test for references code lens including imports
Fix references code lens to include imports as references
Dec 12, 2025
The previous fix was adding imports to singleReferences and adding skip logic in getReferencesAtLocation, but this approach was not based on the original TypeScript implementation and caused: - Doubled reference ranges like [|[|B|]|] - Regressions in goToImplementation tests This reverts to the original behavior while keeping the fourslash test that demonstrates the issue (showing 0 references for now). Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Contributor
Author
Reverted the incorrect fix in commit aaefcb7. The test is kept to demonstrate the issue, but the baseline now shows the current behavior (0 references). A proper fix requires more careful analysis of how TypeScript handles |
Jake Bailey (jakebailey)
deleted the
copilot/add-fourslash-test-for-references
branch
March 5, 2026 17:58
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.
Status
The fourslash test
codeLensReferencesIncludeImports_test.gois kept to demonstrate the issue. The baseline shows0 referenceswhich is the current (incorrect) behavior.A proper fix requires more careful analysis of how TypeScript handles the difference between
isDefinitionmarking vs Go's per-entry declaration filtering.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.