microsoft / microsoft/TypeScript

Feature Request: Update wrong defined import statements?

Open
#54,201 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

I wonder if there is a feature in vscode to automatically delete imports that are incorrectly defined? Like this:

image

There is no function named "getData" from "response.ts". Because that function is moved somewhere else within the project. I ask this because incorrectly defined import statements are not deleted automatically by "removeUnusedImports". Because they are used in the file.

In fact, if it could be deleted, then the "addMissingImports" command could do its job and add these imports to the file, so that we could see that the function that was moved in the project was imported from the right place.

PLUS, it would be great if this feature could work when functions are relocated, just like vscode detects when files are relocated and updates the imports. But I am not sure about feasibility of this.

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 by examining how the existing removeUnusedImports and addMissingImports commands handle imports whose exported function has moved. Define the expected behavior for incorrectly defined imports and relocated functions, then verify that the proposed feature can identify the correct new source without deleting valid imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.