Error Argument of type '{ [x: string]: any; }' is not assignable to parameter of type 'Contact'. Type '{ [x: string]: any; }' is missing the following properties from type 'Contact': id, contactType, name ts(2345)
const contact: {
[x: string]: any;
}
I have a problem with this error. I'm trying to download a contact in my expo app.
My Code download.tsx:
const downloadContact = async (customer: any) => {
if(hasContactPermission) {
const contact = {
[Contacts.Fields.Name]: customer.name,
[Contacts.Fields.Emails]: customer.email,
[Contacts.Fields.PhoneNumbers]: customer.phone,
};
const contactId = await Contacts.addContactAsync(contact);
}
}
I think you are having an issue with the type inference, the contact object you are sending lacks on required parameters like
id, contactType, name, etc. For properties that you don't currently have you have to use the?operator to mark that they can beundefinedAnd the method to add contacts should be something like