You need to pass an object compatible with the List
interface, which is an array with a length:
/// <reference path="underscore.d.ts" />
var list: List;
list[0] = 1;
list[1] = 2;
list[2] = 3;
list.length = 3;
_.countBy(list, function (item) {
return item % 2;
});
In all honesty, an array technically fulfils this as it has a length property - but the above code compiles.
The shorthand version of this is a bit nasty:
/// <reference path="underscore.d.ts" />
var list = <List><any> [1, 2, 3];
_.countBy(list, function (item) {
return item % 2;
});