IList interface for collections

Topics: General, Language Specification
Jan 18, 2013 at 8:21 PM
Edited Jan 26, 2013 at 1:07 AM

jQuery objects are in many cases treated like arrays and directly passed to libraries that work with collections. Underscore.js is a good example. It makes sense to have an IList interface at lib.d.ts so that both Array and jQuery declarations can implement and then get underscore methods to just accept IList instead of having to overload any[] and JQuery parameters on every underscore function.

I'm sure an IList interface or something like that will be useful also in other similar cases for other libraries.

Related issue:



Jan 18, 2013 at 9:54 PM
Edited Jan 18, 2013 at 9:55 PM

Once is complete, I would hope something like this:

interface Indexable {
    [index: number]: any;

would satisfy arrays.

Jan 26, 2013 at 1:19 AM
Edited Jan 26, 2013 at 1:19 AM

Thanks. I used the following as the common interface between arrays and jQuery objects:

interface IList {
    [index: number]: any;
    length: number;