Loading lib/jsduck/type_parser.rb +7 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,9 @@ module JsDuck # The basic type # # <varargs-type> ::= [ "..." ] <array-type> | <array-type> [ "..." ] # <varargs-type> ::= [ "..." ] <null-type> | <null-type> [ "..." ] # # <null-type> ::= [ "?" | "!" ] <array-type> # # <array-type> ::= <type-name> [ "[]" ] # Loading @@ -76,6 +78,10 @@ module JsDuck @out << "..." end if nullability = @input.scan(/[?!]/) @out << nullability end type = @input.scan(/[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*|\*/) if !type Loading spec/type_parser_spec.rb +13 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,19 @@ describe JsDuck::TypeParser do parse("...*...").should == false end it "matches the nullable notation" do parse("?String").should == true end it "matches the non-nullable notation" do parse("!String").should == true end it "doesn't matches both nullable and non-nullable at the same time" do parse("?!String").should == false parse("!?String").should == false end end end Loading Loading
lib/jsduck/type_parser.rb +7 −1 Original line number Diff line number Diff line Loading @@ -59,7 +59,9 @@ module JsDuck # The basic type # # <varargs-type> ::= [ "..." ] <array-type> | <array-type> [ "..." ] # <varargs-type> ::= [ "..." ] <null-type> | <null-type> [ "..." ] # # <null-type> ::= [ "?" | "!" ] <array-type> # # <array-type> ::= <type-name> [ "[]" ] # Loading @@ -76,6 +78,10 @@ module JsDuck @out << "..." end if nullability = @input.scan(/[?!]/) @out << nullability end type = @input.scan(/[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*|\*/) if !type Loading
spec/type_parser_spec.rb +13 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,19 @@ describe JsDuck::TypeParser do parse("...*...").should == false end it "matches the nullable notation" do parse("?String").should == true end it "matches the non-nullable notation" do parse("!String").should == true end it "doesn't matches both nullable and non-nullable at the same time" do parse("?!String").should == false parse("!?String").should == false end end end Loading