microsoft / microsoft/TypeScript

Enable auto imports and add missing import for module/package names

Open
#52,527 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: LS: Auto-import Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Suggestion

🔍 Search Terms

  • auto import
  • quick fix
  • missing import

⭐ Suggestion

Auto imports / add missing imports should be able to add import * as XYZ from 'XYZ' when triggered on the symbol name XYZ in a file. This is useful if you prefer using namespace imports and can also help with discovering/exploring new packages

Right now we have auto imports and an add missing import quick fix for symbols in a module, but I don't see these options for the module itself

📃 Motivating Example

  1. In a new project
  2. npm I @types/vscode
  3. Open new TS file and write vscode.

Right now I don't get an auto import for vscode. I'd expect an import that adds: import * as vscode from 'vscode'; at the top of the file

💻 Use Cases

  • Make it easier to reference a symbol if you prefer using namespaces from the start
  • Helping users explore new packages (just type vscode. to see suggestions in the vscode package)
  • Working with node packages. It'd be nice to be able to type fs. to get an fs import
  • Fixing code that has been copy and pasted between files

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

No files, tests, or entry points are named. Start by reproducing the TypeScript example with vscode. and compare the existing auto-import and add-missing-import behavior for symbols. Done means a module name can trigger a namespace import such as import * as vscode from 'vscode'; in the scenarios described.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.