hegemonic / catharsis

A JavaScript parser for Google Closure Compiler and JSDoc type expressions.
MIT License
54 stars 14 forks source link

Type-expression parser should handle nested type unions without enclosing in parentheses. #47

Open jdalton opened 8 years ago

jdalton commented 8 years ago

Lodash is looking into using jsdoc and we're running into issues

The type-expression parser doesn't handle nested type unions unless all of the type unions are enclosed in parentheses. So for example this fails:

{Function|...(string|string[])}

but this is ok

{(Function|...(string|string[]))}
hegemonic commented 8 years ago

I'm open to implementing this, but I think I tried once already and ended up flailing. You might be better off biting the bullet and enclosing your type unions in parentheses, as in the second example.

justinhelmer commented 8 years ago

Wouldn't be too difficult to do a global search & replace for future releases, but there still remains the concern of generating documentation for releases that have already been published. For this, there would need to be some sort of preprocessing layer in order to correctly generate the markdown for legacy releases.