hegemonic / catharsis

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

Provide an option that enforces the documented syntax for Closure Compiler type expressions #37

Closed pigulla closed 7 years ago

pigulla commented 9 years ago

Unless the jsdoc option is set, the following code should throw an exception because the type expression null|function is invalid (type unions must be within parentheses):

var catharsis = require('catharsis');

catharsis.parse('null|function()');

As I understand it, this behaviour was introduced in #8.

hegemonic commented 9 years ago

Catharsis always accepts these type unions as valid because Closure Compiler does, too. Similarly, both Catharsis and Closure Compiler allow the nullable (?) and non-nullable (!) operators to be used in postfix form (for example, string!). See #20 for more background.

That said, I'm open to adding a new option (perhaps called strict) that only accepts the documented syntax for type expressions. I can imagine how that might be useful for a style-checking tool.

I probably won't implement this anytime soon, but I'd welcome a pull request for the feature.

hegemonic commented 7 years ago

Closing this due to lack of interest.