IList interface for collections

Topics: General, Language Specification
Jan 18, 2013 at 7:21 PM
Edited Jan 26, 2013 at 12: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 8:54 PM
Edited Jan 18, 2013 at 8:55 PM

Once is complete, I would hope something like this:

interface Indexable {
    [index: number]: any;

would satisfy arrays.

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

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

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