Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.d.ts emit drops JSDoc when generating overload signatures from JSDoc @overload #53350

Closed
aduth opened this issue Mar 19, 2023 · 3 comments Β· Fixed by #54846
Closed

.d.ts emit drops JSDoc when generating overload signatures from JSDoc @overload #53350

aduth opened this issue Mar 19, 2023 · 3 comments Β· Fixed by #54846
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@aduth
Copy link

aduth commented Mar 19, 2023

Bug Report

πŸ”Ž Search Terms

  • overload
  • jsdoc

πŸ•— Version & Regression Information

5.0.2

  • I was unable to test this on prior versions because this is newly introduced in 5.0

⏯ Playground Link

Broken JavaScript/JSDoc version (see missing comment documentation in .d.ts output):

For comparison, see working TypeScript version (see included comment documentation in .d.ts output):

This snippet of code was adapted from the announcement post description.

πŸ’» Code

// @ts-check

/**
 * Function description.
 * 
 * @overload
 * @param {string} value Param value description.
 * @return {void} Return value description.
 */

/**
 * Function description.
 * 
 * @overload
 * @param {number} value Param value description.
 * @param {number} [maximumFractionDigits] Param maximumFractionDigits description.
 * @return {void} Return value description.
 */

/**
 * Function description.
 * 
 * @param {string | number} value Param value description.
 * @param {number} [maximumFractionDigits] Param maximumFractionDigits description.
 */
function printValue(value, maximumFractionDigits) {
  // ...
}

πŸ™ Actual behavior

There are no docblock comments in generated .d.ts.

Screenshot from broken JavaScript/JSDoc code snippet:

image

πŸ™‚ Expected behavior

Generated .d.ts includes docblock comment descriptions for function, parameters, and return value of overloaded forms.

Screenshot from working TypeScript playground link above:

image

aduth added a commit to johnhooks/hpq that referenced this issue Mar 19, 2023
This is checked-in to source control include manual revisions documenting overloaded functions, due to a suspected upstream bug in TypeScript.

See: microsoft/TypeScript#53350
@fatcerberus
Copy link

Just letting you know, you swapped the expected and actual behavior (but not the corresponding screenshots, oddly).

@aduth
Copy link
Author

aduth commented Mar 19, 2023

Just letting you know, you swapped the expected and actual behavior (but not the corresponding screenshots, oddly).

Thanks! I updated the original text.

johnhooks pushed a commit to johnhooks/hpq that referenced this issue Mar 19, 2023
This is checked-in to source control include manual revisions documenting overloaded functions, due to a suspected upstream bug in TypeScript.

See: microsoft/TypeScript#53350
aduth added a commit to aduth/hpq that referenced this issue Mar 25, 2023
* feat: enhance types

* docs: fix JSDoc parameter alignment

* chore: upgrade to TS 5.0

* fix: generic parameters

* fix: all type errors

* chore: fix indentation of comments

* chore: collapse comments

* fix: remove .ts file

* Check-in type declaration file

This is checked-in to source control include manual revisions documenting overloaded functions, due to a suspected upstream bug in TypeScript.

See: microsoft/TypeScript#53350

* Remove extra param tags

* feat: add typescript

* refactor: convert get-path to typescript

* feat: enhance types

add TypeScript

* chore: upgrade to TS 5.0

* fix: generic parameters

* chore: collapse comments

* Check-in type declaration file

This is checked-in to source control include manual revisions documenting overloaded functions, due to a suspected upstream bug in TypeScript.

See: microsoft/TypeScript#53350

* feat: convert to TypeScript

* fix: apply @aduth's suggestions

* chore: remove unnecessary type assertion

* chore: apply @aduth's review suggestions

---------

Co-authored-by: Andrew Duthie <[email protected]>
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Mar 30, 2023
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.2.0 milestone Mar 30, 2023
@sandersn sandersn changed the title JSDoc @overload directive drops function description comments in type declaration .d.ts emit drops JSDoc when generating overload signatures from JSDoc @overload Jun 29, 2023
@sandersn
Copy link
Member

This is most likely because @overload doesn't use the normal jsdoc host rules [1], so the common JSDoc code path in the .d.ts emitter won't work. But it might be some other oversight in .d.ts emit.

[1] In the example, there are 3 separate jsdoc comments before printValue. Every tag besides @overload only applies when it's the jsdoc comment right before its function. But the syntax of @overload requires separate comments to disambiguate the end of overload signatures and the beginning of the implementation signature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants