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

can NaN be used as a default param value? #1597

Open
75lb opened this issue Jan 8, 2019 · 1 comment
Open

can NaN be used as a default param value? #1597

75lb opened this issue Jan 8, 2019 · 1 comment

Comments

@75lb
Copy link

75lb commented Jan 8, 2019

If I set NaN as a default param value (see param 3 below)...

/**
 * Example.
 *
 * @param {number} arg1=1
 * @param {number} arg2=something
 * @param {number} arg3=NaN
 */
function example (arg1, arg2, arg3) {}

...then, in the explain output the defaultValue is returned as null - a different value.

[
    {
        "comment": "/**\n * Example.\n *\n * @param {number} arg1=1\n * @param {number} arg2=something\n * @param {number} arg3=NaN\n */",
        "meta": {
            "range": [
                111,
                149
            ],
            "filename": "issue-170.js",
            "lineno": 8,
            "columnno": 0,
            "path": "/Users/llobrook/Documents/jsdoc2md/testbed/tmp",
            "code": {
                "id": "astnode100000002",
                "name": "example",
                "type": "FunctionDeclaration",
                "paramnames": [
                    "arg1",
                    "arg2",
                    "arg3"
                ]
            }
        },
        "description": "Example.",
        "params": [
            {
                "type": {
                    "names": [
                        "number"
                    ]
                },
                "defaultvalue": 1,
                "name": "arg1"
            },
            {
                "type": {
                    "names": [
                        "number"
                    ]
                },
                "defaultvalue": "something",
                "name": "arg2"
            },
            {
                "type": {
                    "names": [
                        "number"
                    ]
                },
                "defaultvalue": null,
                "name": "arg3"
            }
        ],
        "name": "example",
        "longname": "example",
        "kind": "function",
        "scope": "global"
    },
    {
        "kind": "package",
        "longname": "package:undefined",
        "files": [
            "/Users/llobrook/Documents/jsdoc2md/testbed/tmp/issue-170.js"
        ]
    }
]

Is it possible to represent NaN correctly in the returned explain JSON?

@75lb
Copy link
Author

75lb commented Jan 8, 2019

Is it safe to assume the null value should be interpreted as NaN if one of the type names for that param is number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant