Commit 97d02f25 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix extra required configs caused by {Type=} implementation.

Because {Type=} defined an optional item, it was taken granted that
just {Type} would define a required item.  Not so fast - while
params default to being required, configs default to being optional.
parent accf6953
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@ module JsDuck
      if look(/\{/)
        tdf = typedef
        @current_tag[:type] = tdf[:type]
        @current_tag[:optional] = tdf[:optional]
        @current_tag[:optional] = true if tdf[:optional]
      elsif look(/\S/)
        @current_tag[:type] = @input.scan(/\S+/)
      end
@@ -362,7 +362,7 @@ module JsDuck
      if look(/\{/)
        tdf = typedef
        @current_tag[:type] = tdf[:type]
        @current_tag[:optional] = tdf[:optional]
        @current_tag[:optional] = true if tdf[:optional]
      end
    end

@@ -452,7 +452,7 @@ module JsDuck
        name = name.chop
        optional = true
      else
        optional = false
        optional = nil
      end

      match(/\}/)
+14 −0
Original line number Diff line number Diff line
@@ -104,6 +104,20 @@ describe JsDuck::Aggregator do
    end
  end

  describe "cfg without optionality type annotation {Foo=}" do
    before do
      @cfg = parse(<<-EOS)[0]
        /**
         * @cfg {Number} foo Something
         */
      EOS
    end

    it "doesn't default to required" do
      @cfg[:meta][:required].should_not == true
    end
  end

  describe "parameter with explicit default value" do
    before do
      @param = parse(<<-EOS)[0][:params][0]