I am currently working on a TypeScript API, which requires some additional features binding to the Object prototype (Object.prototype).
Consider the following code:<
I used to have:
// See if an array contains an object
Array.prototype.contains = function (obj) {
var i = this.length;
while (i--) {
if (this[i] === obj) {
return true;
}
}
return false;
}
in order to make that code compile with typescript I added the line:
interface Array {
contains(obj: Object): boolean;
}
Thanks basarat!