Skip to content

Fix import statement completion filtering in tsgo - #64357

Merged
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
yksr-melt:fix/tsgo-import-completion-filter
Sep 21, 2026
Merged

Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
yksr-melt:fix/tsgo-import-completion-filter

Conversation

@yksr-melt

@yksr-melt 雪代 / Yukishiro (yksr-melt) commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #64270

With tsgo (TypeScript 7), VS Code does not show auto-import completions inside named imports such as import { and import { fo.

Import statement completions replace the whole statement typed so far, so the edit range of each item starts at import. VS Code matches the text from the start of that range to the cursor against the item's filterText. filterText was only the export name (foo), so every candidate was filtered out on the client.

This sets the filterText of import statement completions to the generated statement (insertText, e.g. import { foo$1 } from "./mod";). Other completions are not affected.

#64270 was reported against 7.0.2, which predates microsoft/typescript-go#3949 and returns no import statement candidates at all. This change addresses the remaining client-side filtering for builds that include it.

Testing

Added tsc/internal/fourslash/tests/importStatementCompletions_braces_test.go, which covers import { and import { fo. It checks FilterText together with InsertText, the text edit range and the auto-import data. Both tests fail without the change; the existing import statement completion tests did not assert FilterText.

Local verification:

  • npx hereby check:format: passed.
  • go test ./... in tsc (what npx hereby test runs): all packages passed.
  • golangci-lint with the repo's custom build and .golangci.yml on the tsc module (what npx hereby lint runs first): 0 issues. The tools module could not be linted on my machine because some of its dependencies are not available offline; this change does not touch it.

AI assistance

I used Claude Code to help investigate the issue, write the change and the tests, and draft this description. I chose this issue, have reviewed the change, and will follow up on review feedback.

Copilot AI balanced review requested due to automatic review settings September 20, 2026 05:24
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 20, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused implementation matches the completion edit range and is covered by targeted regression tests.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes tsgo auto-import completions being filtered out inside named imports.

Changes:

  • Uses the generated import statement as completion filterText.
  • Adds fourslash coverage for bare braces and partial names.
File Description
tsc/​internal/​ls/​completions.go Corrects import completion filtering.
tsc/​internal/​fourslash/​tests/​importStatementCompletions_braces_test.go Adds regression tests.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@yksr-melt

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 21, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into microsoft:main with commit 36482c8 Sep 21, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Auto-import completions are not shown inside named imports with TypeScript 7 / tsgo

3 participants