Skip to content
New issue

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

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

Already on GitHub? # to your account

Unable to specify NaN as a default value #170

Open
fasttime opened this issue Sep 24, 2018 · 5 comments
Open

Unable to specify NaN as a default value #170

fasttime opened this issue Sep 24, 2018 · 5 comments

Comments

@fasttime
Copy link

Using jsdoc-to-markdown 4.0.1 on the following sample file (call it "example.js").

/**
 * Example function.
 *
 * @param {number} arg1=-1.23 - An argument
 * @param {number} arg2=Infinity - Another argument
 * @param {number} arg3=NaN - Yet another argument
 * @returns {undefined} nothing
 */
function example (arg1, arg2, arg3) {}

Running jsdoc-to-markdown example.js produces this output:

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| arg1 | <code>number</code> | <code>-1.23</code> | An argument |
| arg2 | <code>number</code> | <code>Infinity</code> | Another argument |
| arg3 | <code>number</code> | <code></code> | Yet another argument |

Note that the default value NaN for the third argument does not appear in the output.

@75lb
Copy link
Member

75lb commented Sep 25, 2018

Interesting. Does this source code document as expected using jsdoc?

@fasttime
Copy link
Author

Yes, it does. At least with current jsdoc 3.5.5.

@75lb
Copy link
Member

75lb commented Jan 8, 2019

Hi, this is an issue with jsdoc which returns null instead of NaN in its JSON output. I'm assuming it works in their template because they interpret the combination of type name number used with default value null to actually mean default value NaN. I asked on the jsdoc issue I raised, will get back to you.

@e2tha-e
Copy link

e2tha-e commented Jan 8, 2019

This behavior also occurs when specifying null or undefined as a default value.

@sgoumaz
Copy link

sgoumaz commented Jul 11, 2022

Adding to the last comment: if jsdoc returns null, I expect jsdoc-to-markdown to output null, not nothing. So I think there are two issues here:

  1. jsdoc outputs null for NaN – to be fixed/clarified over on the jsdoc side
  2. jsdoc-to-markdown outputs nothing for null or undefined – to be fixed here

# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

4 participants