I have been working with an Interface
, where I created an array of type Interface
. I am currently facing some IDE error complaints when trying to use the .indexOf
method on the Array. These errors seem confusing to me, and I'm hoping someone here might be able to offer a solution.
Interface
export interface IAddress {
name: string,
registrationId: number
}
Code
let friends: IAddress[];
// assume friends has a few elements...
let index = friends.indexOf((friend: IAddress) => {
return !!(friend.name === 'some name');
});
TypeScript Errors:
Argument of type '(friend: IAddress) => boolean' is not assignable to parameter of type 'IAddress'.
Type '(friend: IAddress) => boolean' is missing the following properties from type 'IAddress': registrationId
If I were to remove the :IAddress
from the typed def next to friend:
I see this error instead.
Argument of type '(friend: any) => boolean' is not assignable to parameter of type 'IAddress'.
Type '(friend: any) => boolean' is missing the following properties from type 'IAddress': registrationId