I have created my own extensions to Array as below:
export interface Func<T, TResult> {
(item: T): TResult;
}
declare global {
interface Array<T> {
where(predicate: Func<T, boolean>): Array<T>;
single(predicate: Func<T, boolean>): T;
first(predicate: Func<T, boolean>): T;
take(predicate: Func<T, boolean>, count: number): Array<T>;
countWhere(predicate: Func<T, boolean>): number;
count(): number;
}
}
Array.prototype.count = function <T>(): number {
return this.length;
}
//others
In any of my component intellisense shows me these methods as extensions but while debugging I get undefined for example:
events: Event[];
var result = this.events.count();
Where should I implement Array methods so they could be visible from any component?