I am trying to learn more about advanced externs for Closure Compiler by trying to make a rudimentary extern for JQueryUI (1.9.2). I am using the JQuery 1.8 extern to help.
So here is some silly code:
$( "#someSortable" ).sortable(
{ "cancel":".static",
"change":function( event, ui )
{ var thisindex = $( ui.helper ).index( );
}
});
$( "#someSortable" ).disableSelection( );
$( "#someSortable" ).sortable( "refresh" );
$( "#someTabs" ).tabs( );
And here is my attempt at an extern:
/**
* @param {Object|string} param
* */
jQuery.prototype.sortable = function( param ) {};
jQuery.prototype.tabs = function() {};
The tabs compile okay, but the sortable runs into trouble:
WARNING - Property helper never defined on ui
WARNING - Property disableSelection never defined on jQuery
Any suggestions how to augment my javascript or my extern to make this work without warnings in closure compiler?
What is the ui object? What is the type of this object?
On Mon, Dec 31, 2012 at 9:31 PM, Erik Blankinship <jedi...@gmail.com> wrote:On Mon, Dec 31, 2012 at 6:40 PM, Ilia Mirkin <imi...@alum.mit.edu> wrote:What is the ui object? What is the type of this object?In this case, ui is a javascript object with a variety of different keys andvalues. One of the keys is helper, and its value is an element.
That's not good enough for closure compiler. It wants to know the
type. And if you don't want "helper" renamed, it had better match the
typename of one of the externs.
If you don't know the type, you can throw your hands up in the air,
and say ui['helper'], no questions asked. But then you lose any form
of type checking, etc
Would I expand this definition? What would that look like?