microsoft / microsoft/TypeScript

Unable to retain JSDocs for higher order function

Abierto
#53,167 5 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Domain: JSDoc Needs Proposal Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza reproduciendo el problema con el ejemplo de la función de orden superior y una transpilación que emita declaraciones; después, compara el resultado del código fuente local con lo que puede ver el consumidor de la versión publicada. Investiga cómo la salida transpilada y declarationMap gestionan el JSDoc de la función devuelta. Se considera terminado cuando el comentario se conserva y es visible para los consumidores después de la transpilación.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.