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

JSDoc does not correctly parse the default value of the property tag #2078

Open
QianSeNianHua opened this issue Sep 8, 2023 · 0 comments
Open

Comments

@QianSeNianHua
Copy link

QianSeNianHua commented Sep 8, 2023

JSDoc code

jsdoc/tag/type.js
jsdoc/util/cast.js

function parseName(tagInfo) {
    // like '[foo]' or '[ foo ]' or '[foo=bar]' or '[ foo=bar ]' or '[ foo = bar ]'
    // or 'foo=bar' or 'foo = bar'
    if ( /^(\[)?\s*(.+?)\s*(\])?$/.test(tagInfo.name) ) {
         ^^^^^^^^^^^^^^^^^^^^^^^^^
        tagInfo.name = RegExp.$2;
        // were the "optional" brackets present?
        if (RegExp.$1 && RegExp.$3) {
            tagInfo.optional = true;
        }

        // like 'foo=bar' or 'foo = bar'
        if ( /^(.+?)\s*=\s*(.+)$/.test(tagInfo.name) ) {
            tagInfo.name = RegExp.$1;
            tagInfo.defaultvalue = jsdoc.util.cast.cast(RegExp.$2);
        }
    }

    return tagInfo;
}

Current behavior

My comment is @property {Array<String>} [name=[" 1 "]] description, and it seems to typecast the string.
Why is there no conversion to object format. Please see
jsdoc/util/cast.js

Output behavior

The default value is [" 1 ".

Your environment

Software Version
JSDoc 4.0.2
Node.js 14.21.2
npm 6.14.17
@QianSeNianHua QianSeNianHua changed the title JSDoc does not parse the default value of the property tag JSDoc does not correctly parse the default value of the property tag Sep 8, 2023
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