microsoft / microsoft/TypeScript

Unable to retain JSDocs for higher order function

Aperta
#53,167 5 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

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.

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 riproducendo il problema con l'esempio della funzione di ordine superiore e una transpilazione che emetta dichiarazioni, quindi confronta il risultato del sorgente locale con ciò che può vedere il consumer della versione pubblicata. Analizza come l'output transpilato e declarationMap gestiscono il JSDoc della funzione restituita. Il lavoro è completato quando il commento viene mantenuto ed è visibile ai consumer dopo la transpilazione.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.