Closed
Description
In a situation a different user has written code that puts the email of a client to the id field as this is needed for the way the multiselect is written. The problem I am facing is that in the interface I have made the type of the email field string | null
as we do have clients that haven't yet fully given their information yet. In the old situation they didn't respect a possible null value.
Because of that I thought of trying to fix this with a filter.
const contacts =
thisClient.value?.contacts
?.filter(contact => props.form.contactAttendeeIds.includes(contact.id))
.filter(contact => contact.email !== null)
// Typescript still doesn't recognize that this can't be null anymore.
.map(contact => ({...contact, ...{id: contact.email as string}})) ?? [];
Because it doesn't recognize that the value can no longer be null it still throws type errors in our pipeline.
It this something that can be fixed or a problem I need to tackle differently?