microsoft / microsoft/TypeScript
Unable to retain JSDocs for higher order function
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the higher-order function example and a transpilation that emits declarations, then compare the local source result with what the published consumer can see. Investigate how the transpiled output and declarationMap handle the returned function's JSDoc. Done means the comment is retained and visible to consumers after transpilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100