microsoft / microsoft/TypeScript

Unable to retain JSDocs for higher order function

オープン
#53,167 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: JSDoc Needs Proposal Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、高階関数の例と宣言を出力するトランスパイルを使って問題を再現し、次にローカルのソース結果と、公開されたバージョンの consumer が確認できる内容を比較します。トランスパイルされた出力と declarationMap が、返される関数の JSDoc をどのように扱うかを調査します。トランスパイル後もコメントが保持され、consumer から見える状態になれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。