microsoft / microsoft/TypeScript

Emit errors for rogue jsdoc tags

Offen
#53,104 0 Kommentare 0 Reaktionen 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

🔍 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

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

Prüfe zuerst die vorgeschlagenen JSDoc-Beispiele und das zugehörige Issue #47222 und verfolge anschließend, wie JSDoc-Tags in JavaScript derzeit akzeptiert werden. Die Änderung ist abgeschlossen, wenn ungewöhnliche oder unerwartete Tag-Positionen Diagnosen erzeugen, ohne die Laufzeitausgabe zu ändern, und die cast- und function-Beispiele abgedeckt sind.

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.