microsoft / microsoft/TypeScript

JSDoc type aliases aren't parsed or bound at the end of blocks

Offen
#54,043 0 Kommentare 0 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.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

Bug Report

Followup to #54037 and #53624
This is not a regression, and fixing it would require

  • the parser to check for jsdoc before each close brace
  • the ast to store optional jsdoc on each close brace, and store the close brace on each block
  • the binder to visit each close brace to check for jsdoc to bind

So I think it's too expensive for a feature that nobody has noticed missing until recently.

🔎 Search Terms

JSDoc type alias ignored

🕗 Version & Regression Information
  • This is the behavior in every version I tried
💻 Code
// @filename: typedefAtEndOfBlock.js
// @checkJs: true
// @outdir: dist
// @declaration: true
function f() {
  /* @type {A} */
  var a = 2
  /** @typedef {string} A */
}
{
  /* @type {B} */
  var b = 2
  /** @typedef {string} B */
}
export class Class {
  /* @type {C} */
  c = 1
  /** @typedef {string} C */
}
const Dlass = class {
  /* @type {D} */
  d = 1
  /** @typedef {string} D */
}
🙁 Actual behavior

None of the typedefs are parsed or bound.

🙂 Expected behavior

The typedefs are parsed and bound.
(And none are visible outside their containers, which is not true for classes right now).

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 Reproduktion in typedefAtEndOfBlock.js und verfolge, wie parser, AST und binder JSDoc vor schließenden geschweiften Klammern behandeln. Vergleiche das in #54037 und #53624 beschriebene Verhalten. Als abgeschlossen gilt die Aufgabe, wenn die typedefs innerhalb ihrer Container geparst und gebunden werden und das dokumentierte Verhalten zur Sichtbarkeit von class behoben ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.