Nathan
With these inputs:
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
jQuery
Seemed to do the job.
Eric
Nice work, Chad. I'm glad you decided to write a program to generate
the externs file from jQuery's documentation rather than to write the
externs manually. The type annotations help a great deal. We've
already uncovered a few misuses of jQuery in our codebase. And I'm
sure future misuse will be much harder now that we have a
type-annotated externs file.
That said, a few things are missing:
.attr(arg1, arg2)
http://api.jquery.com/attr/
(One argument overload works, two doesn't.)
.css(arg1, arg2)
http://api.jquery.com/css/
(One argument overload works, two doesn't.)
.html()
http://api.jquery.com/html/
(Should always return just {string} not {(string|jQuery.jQueryObject)}
if I'm not mistaken.)
$(window)
http://api.jquery.com/jQuery/
$("<div/>", { "class": "test" })
http://api.jquery.com/jQuery/#jQuery2
.unbind()
http://api.jquery.com/unbind/
(Zero argument overload isn't listed in the explicit overloads, but is
mentioned in the description.)
Suggestion: Rename type jQuery.jQueryObject to something shorter, like
just jQueryObject. It's a bit of pain to type it out completely when
I'm writing type annotations for code that interacts with jQuery. It
sure beats having to use plain {Object} though :)
You mentioned you'd post your generator program once all the kinks are
worked out. I'd recommend just releasing it now. Instead of us
complaining about things that aren't supported, we can contribute
patches which add the correct support.
Eric
Whoops, I was mistaken. .html() with a parameter returns the original
jQuery object. It's a shame we can't specify return types based on
what parameters were received because, unless coaxed, any type-checked
code that relies on the return value of .html() complains that it
might potentially be receiving a jQuery.jQueryObject.
Eric
-Add {string|number} to arg2 of attr()
-Add {number} to arg1 of .val()
-unbind()
You would prefer to wait for jQuery's docs to be updated instead of
tweaking the generated externs file?
Eric
It is usually best to wrap these types of issues in a simple function and let the compiler inline it (so the is no runtime overhead).
sent from a mobile phone excuse the spelling ...