/**
* Load email records and
* update the corresponding ocntact fields.
*/
export async function loadContactEmails(contact, db) {
contact.emails =
await db.emails.where('contactId').equals(contact.id).toArray();
}
This resulted in the following error in strict Typescript:
src/app/core/services/database/utilities.ts:16:50 - error TS7006: Parameter 'db' implicitly has an 'any' type.
Solution
The problem with this strict type of programming is that TypeScript requires to know which type of parameters it gets inside its functions. In this case it are both objects, so we set the any type:
/**
* Load email records and
* update the corresponding ocntact fields.
*/
export async function loadContactEmails(contact:any, db:any) {
contact.emails =
await db.emails.where('contactId').equals(contact.id).toArray();
}
Other example
Promise.all(contact.emails.map((email) => db.emails.put(email))),
Solution
Promise.all(contact.emails.map((email:string) => db.emails.put(email))),
This actually makes your code much better. Make sure you never turn off strict typing!