microsoft / microsoft/TypeScript

Emit errors for rogue jsdoc tags

Aperta
#53,104 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Suggestion

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
jsdoc rogue type tag

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Emit an error for jsdoc tags that have an unusual or unexpected position.

📃 Motivating Example

Say you want to cast a value but you forget the brackets around the value you want to cast:

const x = /** @type {you can pretty much type anything here} */ 3;

At the moment no error is emitted at all, but it seems like this shouldn't be legal.

💻 Use Cases

/**
 * @param {any} data
 */
function sanitizeData(data) {
    // ... sanitize
    return /** @type {SanitizedType} */ data;
}

It's easy to miss that this function has any as return type, rather than the SanitizedType you'd expect.


Note that even though this would be a breaking change, this change would likely only highlight code that was already broken and not type safe, rather than introduce new issues.

Related #47222

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

Esamina prima gli esempi JSDoc suggeriti e l’issue correlata #47222, quindi traccia il modo in cui i tag JSDoc vengono attualmente accettati in JavaScript. La modifica è completa quando posizioni insolite o impreviste dei tag producono diagnostica senza modificare l’output di runtime, con copertura per gli esempi cast e function.

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.