microsoft / microsoft/TypeScript

From-first import statement completion

Open
#43,670 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Suggestion

import, completion, reverse, inverse, from-first

✅ Viability Checklist

This would be a completion feature for the language server, with no impact on the compiler or language syntax.

⭐ Suggestion

A smoother developer experience for completing imports when the symbol is unknown and the package is.

This is the opposite of the new symbol-first import completion feature proposed for TS 4.3.

📃 Motivating Example

The symbol-first import completion feature is interesting, but I think it somewhat misses a real-world context. Bottom line is that, as developers, we hardly ever actually spend time at the top of the file manually writing imports.

Whenever I know the symbol I want to import, I am usually writing it in-line in my code block, and TS Lang Server is able to complete the import based on its usage. This is 99% of the cases in which I am importing a symbol whose name I know. From this perspective, having completion for import { myFunc } is not so useful.

Given this, the only time I'm actually at the top of a file writing import statements is usually when I know the name of the package, but I don't know exactly what the symbol name is, or where to start. In this case I end up having to write import { } from 'myPackage'; and then going back to the { } and triggering completion.

It would be a small improvement, but being able to write from 'myPackage' and being presented with the list of symbols to select from would be much more relevant in my mind, because the only time we're up the top of the file writing imports is when we DON'T know what symbols we're looking for.

💻 Use Cases

I think the motivating example outlines this sufficiently.

The implementation seems simple. Simple enough at least that a snippet in VSCode or Webstorm ought to be able to match its behaviour.

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 with the TypeScript language server's existing import-completion behavior described in the issue. Reproduce completion after typing from 'myPackage' and compare it with symbol-first import completion; done means the package's symbols are offered without manually inserting an empty import clause.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.