microsoft / microsoft/TypeScript

JSDoc comments emitted a second time even after commenrs on type are emitted

Aperta
#62,453 0 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: Comment Emit Help Wanted
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

JSDoc, emit, comments

🕗 Version & Regression Information

v5.9.2

  • I was unable to test this on prior versions because I was not using TS.
⏯ Playground Link

No response

💻 Code
/**
 * The template passed to generate messages
 *
 * @callback Template
 * @param {...*} args - Arguments to the template
 * @returns {any} The generated message
 */

/**
 * The arguments sent with notify become the input parameters for the template.
 *
 * @typedef {Parameters<Template>} TemplateParams
 */

/**
 * The return value from the template is yielded as the message generated from
 * the subscription. The following types help define this relationship.
 *
 * @typedef {ReturnType<Template>} Message
 */
🙁 Actual behavior

Typescript, when emitting from JSDoc, seems to want to emit the same comments for a type declaration twice:

  • once for the export (good) and
  • once just copying over the JSDoc comment (bad).
/**
 * The template passed to generate messages
 */
export type Template = (...args: any[]) => any;
/**
 * The arguments sent with notify become the input parameters for the template.
 */
export type TemplateParams = Parameters<Template>;
/**
 * The return value from the template is yielded as the message generated from
 * the subscription. The following types help define this relationship.
 */
export type Message = ReturnType<Template>;
/**
 * The template passed to generate messages
 *
 * @callback Template
 * @param {...*} args Arguments to the template
 * @returns {any} The generated message
 */
/**
 * The arguments sent with notify become the input parameters for the template.
 *
 * @typedef {Parameters<Template>} TemplateParams
 */
/**
 * The return value from the template is yielded as the message generated from
 * the subscription. The following types help define this relationship.
 *
 * @typedef {ReturnType<Template>} Message
 */
🙂 Expected behavior

It should emit the comment just once:

/**
 * The template passed to generate messages
 */
export type Template = (...args: any[]) => any;
/**
 * The arguments sent with notify become the input parameters for the template.
 */
export type TemplateParams = Parameters<Template>;
/**
 * The return value from the template is yielded as the message generated from
 * the subscription. The following types help define this relationship.
 */
export type Message = ReturnType<Template>;

or even better (See #61664)

/**
 * The template passed to generate messages
 *
 * @param Arguments to the template
 * @returns The generated message
 */
export type Template = (...args: any[]) => any;
/**
 * The arguments sent with notify become the input parameters for the template.
 */
export type TemplateParams = Parameters<Template>;
/**
 * The return value from the template is yielded as the message generated from
 * the subscription. The following types help define this relationship.
 */
export type Message = ReturnType<Template>;
Additional information about the issue

No response

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

Riproduci la segnalazione con TypeScript v5.9.2 usando lo snippet JavaScript/JSDoc fornito, quindi traccia il percorso di emissione delle dichiarazioni responsabile dei commenti duplicati. Aggiungi un test di regressione per le dichiarazioni emesse e verifica che ogni commento compaia una sola volta, controllando anche il comportamento correlato a #61664.

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

Valutazione

Stack tecnologico
javascript, 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
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.