microsoft / microsoft/TypeScript
Unable to retain JSDocs for higher order function
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用高阶函数示例以及会生成声明的转译来复现该问题,然后将本地源代码结果与已发布版本的 consumer 能看到的内容进行比较。调查转译后的输出和 declarationMap 如何处理所返回函数的 JSDoc。完成的标准是:注释在转译后仍被保留,并且对 consumer 可见。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100