microsoft / microsoft/TypeScript

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

Aperta
#56,674 2 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Domain: JSDoc Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔍 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 */
}

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando il modo in cui TypeScript analizza e applica attualmente i tag JSDoc nei file JavaScript. Confronta gli esempi richiesti di @var e @member con il comportamento esistente di JSDoc, incluse le dichiarazioni globali e i membri delle classi. Il lavoro è completato quando i tag vengono riconosciuti con i tipi previsti senza modificare il JavaScript emesso e i test coprono gli esempi motivanti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.