microsoft / microsoft/TypeScript

From-first import statement completion

Offen
#43,670 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem im Issue beschriebenen bestehenden Verhalten der Importvervollständigung des TypeScript language server. Reproduziere die Vervollständigung nach der Eingabe von from 'myPackage' und vergleiche sie mit der symbol-first-Importvervollständigung; abgeschlossen ist die Aufgabe, wenn die Symbole des Pakets angeboten werden, ohne manuell eine leere Importklausel einzufügen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.