microsoft / microsoft/TypeScript

Add TS Server command for 'add all missing imports'

Open
#40,921 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Quick Fixes Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search terms

  • code action
  • source action
  • Add missing imports
  • getCombinedCodeFix

Feature request

Add a new TS Server command that triggers 'add all missing imports' for a given file.

Use case

VS Code allows users to configure code actions that are run on save. One of the supported code actions is source.addMissingImports which attempts to add all missing imports in a file. Users can also setup keybindings for these specific actions

To implement this, right now we request all code actions for the file and then try fetching the 'add all missing imports' combined fix for one of them. This is complicated and results in the TS Server doing extra work.

It would be better for us if we could ask the Typescript server: give me the edits that add the missing imports in this file

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript server's existing getCombinedCodeFix handling for the source.addMissingImports action. Trace how commands and file edits are exposed, then verify that the new command returns the edits for adding all missing imports in a given file without requiring the broader code-action request flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.