Having some issues with my generic interface function. Seems like I've been staring at it for too long... Can someone please point out what I'm doing wrong?
This is my Interface:
export interface Compareable<T>
{
equals(compareable:T):boolean;
}
And here's the function:
function isInCompareableArray<T>(compareable:Compareable<T>, arr:Array<Compareable<T>>) : boolean
{
for(let i of arr)
{
if (compareable.equals(i)) return true;
}
return false;
}
Trying to call the function like this:
let dateRef:DateRef //DateRef implements Compareable<DateRef>
let arr:Array<DateRef>
isInCompareableArray<DateRef>(dateRef, arr);
But getting this error message:
ERROR in function ... if (compareable.equals(i)) return true;
...: Argument of type 'Compareable<T>' is not assignable to parameter of type 'T'.
I'm a bit confused here. Any assistance would be greatly appreciated!