microsoft / microsoft/TypeScript

Support `@import` JSDoc tag for auto-imports

Offen
#62,008 3 Kommentare 13 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

🔍 Search Terms

"jsdoc @import", "@import auto-import", "jsdoc auto-import"

✅ Viability Checklist
⭐ Suggestion

Since #57207 it is possible to use the JSDoc @import tag.

/** @import { Foo } from 'foo.js'; */

/** @type {Foo} */
const foo = ...;

However, auto-imports still only use the old inline syntax:

/** @type {import('foo.js').Foo} */
const foo = ...;

It would be nice to also have the option to chose the new @import syntax for the auto-imports, either by configuring an option somewhere or simply by adding another action that can be exposed in IDEs.

📃 Motivating Example

I believe this falls in line with the ergonomics goals outlined by the original issue about having a nicer syntax for JSDoc imports #22160.

I will not repeat the arguments made therein, but suffice to say that it produces more readable code.

💻 Use Cases

Having the auto-import work with this syntax would:

  • Save time, not having to write import statements by hand.
  • Avoid mistakes due to typos, etc.
  • Help people adopt the existing feature.

(I have opened the issue here instead of over in vscode. Based on my understanding, this behavior is exposed by the TypeScript Language Server and not by the individual IDEs. Please correct me if I'm wrong.)

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 der Lektüre des hier beschriebenen Verhaltens des TypeScript Language Server und des Kontexts in den Issues #57207 und #22160. Verfolge, wie auto-imports derzeit Inline-JSDoc-Imports erzeugen, und ermittle anschließend, ob das unterstützte Ergebnis eine Konfigurationsoption oder eine separate Aktion sein sollte; die Aufgabe ist erledigt, wenn auto-imports die angeforderte @import-Syntax erzeugen können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
developer-experience, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
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.