microsoft / microsoft/TypeScript

Support `@var` or `@member` JSDoc tags

Offen
#56,674 2 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

🔍 Search Terms

jsdoc
@var
@member

✅ Viability Checklist
⭐ Suggestion

Recognize and support JSDoc's @var or @member tags.

📃 Motivating Example

It will allow the declaration of globals in JS files that use JSDoc for checking that are not declared within that specific file.

This will then allow for tools and tool chains that add to the global scope for a file or program to be documented without using ts, d.ts or other ts exclusive notation and features.

💻 Use Cases
  1. What do you want to use this for?

Electron preload scripts and contextBridge.exposeInMainWorld!

  1. What workarounds are you using in the meantime?
/**@type {import("./preload.js").ElectronAPI} */
var ElectronAPI;
  1. What shortcomings exist with current approaches?

Relies on JS's support of variable redeclaration. Changing var to let throws the following error on runtime:

Identifier 'ElectronAPI' has already been declared

The following should do the same as the two lines above, but neither vscode nor TS supports it.

/** @var {import("./preload.js").ElectronAPI} ElectronAPI */

It does not rely on confusion inducing variable redeclaration and is much cleaner.

I believe it is also a way to declare members of a class without declaring them at the root level of the class.

These should be the same (as far as TS is concerned):

class test1{
    /**@type {string}*/
    name;
}

class test2{
    /**@var {string} name */
}

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 damit nachzuverfolgen, wie TypeScript derzeit JSDoc-Tags in JavaScript-Dateien parst und anwendet. Vergleiche die angeforderten Beispiele für @var und @member mit dem bestehenden JSDoc-Verhalten, einschließlich globaler Deklarationen und Klassenmitgliedern. Als abgeschlossen gilt die Aufgabe, wenn die Tags mit den beabsichtigten Typen erkannt werden, ohne das ausgegebene JavaScript zu ändern, und Tests die motivierenden Beispiele abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
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.