Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Support string/numeric/boolean literal types #156

Closed
jfirebaugh opened this issue Mar 20, 2016 · 4 comments
Closed

Support string/numeric/boolean literal types #156

jfirebaugh opened this issue Mar 20, 2016 · 4 comments

Comments

@jfirebaugh
Copy link

JSDoc supports, e.g.:

/**
 * @typedef {Object} Comment
 * @property {('public'|'protected'|'private')} access
 */

jsdoc -X output looks like:

...
        "properties": [
            {
                "type": {
                    "names": [
                        "'public'",
                        "'protected'",
                        "'private'"
                    ]
                },
                "name": "access"
            }
        ],
...

This is useful to support enumerated types. See, for instance, jsdoc/jsdoc#629, jsdoc/jsdoc#1065, and documentationjs/documentation#373.

@nzakas
Copy link
Member

nzakas commented Mar 22, 2016

And what happens when you try to parse it with Doctrine? I'm assuming you're saying something isn't working, but a full bug report with what you did, you happened, what you expected, etc. would be very helpful.

@jfirebaugh
Copy link
Author

Ah, yeah, sorry. The comment fails to parse with doctrine. If you have the recoverable option set, you can get back an error message, which is "unexpected token".

@nzakas
Copy link
Member

nzakas commented Mar 25, 2016

I don't have time to look into this at the moment, but I'd be happy to review a pull request.

@mister-walter
Copy link
Contributor

Created #172 to add support for numeric and string literals. Boolean literal support is slightly more complicated, but I can work on that if there is a desire for it.

mister-walter added a commit to mister-walter/doctrine that referenced this issue Aug 22, 2016
Added support to typed.js for string and numeric literals in types.
@nzakas nzakas closed this as completed in 12c7ad9 Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants