senchalabs/jsduck — Issue #75: Better Warning for Subproperty Mismatch
Author: burnnat
Created: 2011-10-12 17:23:49+00:00
State: open

In my documentation, I had a config function with some parameters, and I updated the name of the config option but forgot to change the name of one of the sub-properties. This is what it looked like:

/**
* @cfg {Function} someFn
*
* This is a config function!
*
* @cfg {Object} someFn.firstParam The first parameter you should pass.
* @cfg {Object} oldFn.secondParam The second parameter that I forgot to rename.
*/

When I ran jsduck, it spit back this super-ugly stack trace:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:410:in `block in combine_properties': undefined method `[]' for nil:NilClass (NoMethodError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:406:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:406:in `combine_properties'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:389:in `detect_subproperties'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:171:in `create_cfg'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/merger.rb:18:in `merge'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/source_file.rb:27:in `block in initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/source_file.rb:26:in `map'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/source_file.rb:26:in `initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/app.rb:115:in `new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/app.rb:115:in `block in parallel_parse'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/parallel_wrap.rb:24:in `map'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/parallel_wrap.rb:24:in `map'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/app.rb:113:in `parallel_parse'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/app.rb:46:in `block in run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/timer.rb:26:in `time'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/lib/jsduck/app.rb:46:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/jsduck-3.0.pre2/bin/jsduck:26:in `'
from C:/Ruby192/bin/jsduck:19:in `load'
from C:/Ruby192/bin/jsduck:19:in `

'

Which is understandable, because there's no config option named 'oldFn' any more, but I had no idea what was causing the problem (or the file that it was located in), and it took me a while to narrow it down to this naming mismatch. What would be really nice is a warning similar to the other warnings for things like "Unknown type". Maybe something like:

Warning: Ignoring subproperty: oldFn.secondParam (no parent found with name 'oldFn') in path/to/src.js line 42