microsoft / microsoft/TypeScript

Unable to retain JSDocs for higher order function

Offen
#53,167 5 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Bug Report

When it comes to higher order function, the JSDocs for the resulting function are not persisted after transpile. declarationMap does not help in this regards either.

🔎 Search Terms

jsdocs, comments, higher order function, declarationmap

🕗 Version & Regression Information

4.9.4, but this should happen to all older versions.

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to
https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

Please keep and fill in the line that best applies:
-->

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
⏯ Playground Link

No playground link, as this requires transpilation.

💻 Code
/**
 * this comment retains
 **/
export function higher() {

  /**
   * this comment does not
   **/
  return function() {}
}

When using this code locally, the returning function does get the comment:

const foo = higher()

foo() // comment shows here

But once it is transpiled and published, the consumer of the package will not get the comment,
even if the package include the source, and using declarationMap

🙁 Actual behavior

No JSDocs comment.

🙂 Expected behavior

JSDocs comment should retain to aids consumer of the package.

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, das Problem mit dem Beispiel einer Funktion höherer Ordnung und einer Transpilierung, die Deklarationen ausgibt, zu reproduzieren, und vergleiche dann das Ergebnis der lokalen Quelle mit dem, was der Consumer der veröffentlichten Version sehen kann. Untersuche, wie die transpilierte Ausgabe und declarationMap mit dem JSDoc der zurückgegebenen Funktion umgehen. Als erledigt gilt die Aufgabe, wenn der Kommentar erhalten bleibt und für Consumer nach der Transpilierung sichtbar ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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