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

support for simple Array type #92

Merged
merged 5 commits into from
Aug 24, 2019

Conversation

aidinabedi
Copy link
Contributor

@aidinabedi aidinabedi commented Aug 24, 2019

Fixes support for jsdoc's standalone Array keyword as can be seen in examples such as:

/**
 * Returns the sum of a and b
 * @param {number} a
 * @param {number} b
 * @param {boolean} retArr If set to true, the function will return an array
 * @returns {(number|Array)} Sum of a and b or an array that contains a, b and the sum of a and b.
 */
function sum(a, b, retArr) {
    if (retArr) {
        return [a, b, a + b];
    }
    return a + b;
}

Source: https://jsdoc.app/tags-returns.html

Without this PR, tsd-jsdoc will generate invalid typescript (because outputting just Array will conflict with the built-in generic interface Array<T> ).

@aidinabedi aidinabedi changed the title Support simple array type support simple Array type Aug 24, 2019
@aidinabedi aidinabedi changed the title support simple Array type support for simple Array type Aug 24, 2019
@englercj
Copy link
Owner

Not sure the output you want is simpleArray: []; because that is semantically an empty array of never. Meaning you won't be able to put anything into it, or read anything out of it.

I think the type more similar to what jsdoc expresses would be any[].

@aidinabedi
Copy link
Contributor Author

@englercj You're correct. I've updated the PR.

@englercj englercj merged commit 9846573 into englercj:master Aug 24, 2019
@aidinabedi aidinabedi mentioned this pull request Sep 1, 2019
@aidinabedi aidinabedi deleted the feature/simple-array-support branch April 5, 2020 08:40
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

Successfully merging this pull request may close these issues.

2 participants