microsoft / microsoft/TypeScript

Unable to retain JSDocs for higher order function

Aberta
#53,167 5 comentários 2 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Domain: JSDoc Needs Proposal Suggestion
Linguagem predominante
Go
Estrelas
111k
Forks
14.4k
Merge médio
1d 19h
PRs com merge (30d)
117

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece reproduzindo o problema com o exemplo de função de ordem superior e uma transpilação que emita declarações; depois, compare o resultado do código-fonte local com o que o consumer da versão publicada consegue ver. Investigue como a saída transpilada e declarationMap lidam com o JSDoc da função retornada. A tarefa estará concluída quando o comentário for preservado e estiver visível para os consumers após a transpilação.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
typescript
Domínio
compilers
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
30/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.