jsdoc-to-markdown icon indicating copy to clipboard operation
jsdoc-to-markdown copied to clipboard

Unable to specify NaN as a default value

Open fasttime opened this issue 6 years ago • 5 comments

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.

fasttime avatar Sep 24 '18 20:09 fasttime

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

75lb avatar Sep 25 '18 09:09 75lb

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

fasttime avatar Sep 25 '18 10:09 fasttime

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.

75lb avatar Jan 08 '19 10:01 75lb

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

e2tha-e avatar Jan 08 '19 13:01 e2tha-e

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

sgoumaz avatar Jul 11 '22 16:07 sgoumaz