Skip to content

Implement "find file references"#3277

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-3250
Draft

Implement "find file references"#3277
Copilot wants to merge 3 commits intomainfrom
copilot/fix-issue-3250

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Implements the "find file references" feature (right-click a JS/TS file in VS Code explorer → Find File References), which finds all files that import or triple-slash-reference a given file.

The core challenge: getReferencesForNonModule was a stub, and the multi-project search logic required a document position (which file-level queries don't have).

Changes

Core algorithm (internal/ls/findallreferences.go)

  • Implement getReferencesForNonModule() using program.GetNonModuleFileReferences() to enumerate triple-slash reference directives pointing to a file
  • Add GetFileReferences(ctx, uri) to LanguageService — dispatches to getReferencedSymbolsForModule for module files (has exports), or getReferencesForNonModule for script files

Compiler helper (internal/compiler/program.go)

  • Add GetNonModuleFileReferences(referencedFile)[]NonModuleFileReference to expose fileIncludeReasons data for non-module files (triple-slash refs only; imports are handled via module symbol)

LSP protocol (internal/lsp/lsproto/)

  • Add custom/findFileReferences request: params = FindFileReferencesParams{textDocument} (no position), result = Location[] | null

LSP server (internal/lsp/server.go)

  • Register handleFindFileReferences — queries all projects containing the file, calls GetFileReferences on each, deduplicates results

VS Code extension (_extension/)

  • Add Client.findFileReferences(uri) calling custom/findFileReferences
  • Register _typescript.findAllFileReferences command (the standard VS Code command hooked by the explorer context menu) that calls the above and shows results via editor.action.showReferences

Side effect

Implementing getReferencesForNonModule also fixes findAllReferences on triple-slash /// <reference path/types/lib> nodes — previously they returned no span and omitted transitive referencing files (e.g. require("./b") in a .js file). The findAllReferencesTripleSlash submodule baseline is updated to match TypeScript's expected output, and the stale diff file is removed.

Original prompt

Fix this issue #3250

Created from VS Code.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI and others added 2 commits March 27, 2026 21:59
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/19d44b3e-7bd1-4dc3-8327-ef40363fd5f7

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/19d44b3e-7bd1-4dc3-8327-ef40363fd5f7

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue 3250 in Typescript Go integration Implement "find file references" Mar 27, 2026
Copilot AI requested a review from DanielRosenwasser March 27, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants