Closure compiler externs files for underscore and backbone js

by Luke Rodgers on May 8, 2012

As part of some other things I’m working on I’ve begun building upon some existing closure compiler externs files for the Underscore and Backbone js libraries. Both are still in quite early stages, but if you need something like this, they’re currently better than nothing.

backbone-js-externs on github, for Backbone 0.9.2

underscore-js-externs on github, for Underscore 1.3.3

The Backbone externs file is taken from this gist, which was autogenerated by DotNetWise’s externs extractor. It does a decent but very basic job.

The Underscore externs file is taken from the official Closure Compiler repository. The only changes I’ve made so far are

  • fixing a type annotation for the _.uniq and _.unique functions that had a required parameter after a non-required one (Closure Compiler dislikes this)
  • using same type annotation for _.uniq and _.unique, since the latter is an alias for the former
  • beginning to add type annotations for functional-style usage of underscore, vs. object notation (e.g. _(collection).map(function(){}) vs. _.map(collection, function() {}). The existing externs file has only the latter.

I’ll probably also be adding externs for use with the SVG library Raphael at some point.

3 comments

Thanks for sharing these externs files Luke. I’ve tried to use them but encountered some issues with it. I’ve asked the question on StackOverflow (http://bit.ly/MFpvA2).

by John Keyes on June 20, 2012 at 11:29 am. #

Hey John, just did my best to answer your question at the stackoverflow post. cheers

by Luke Rodgers on June 20, 2012 at 11:41 am. #

Hi Luke, thanks for the answer and apologies for my tardiness in replying.

by John Keyes on June 22, 2012 at 5:23 am. #

Leave your comment

Required.

Required. Not published.

If you have one.