I get this error when running tsc

But when I open the file in VS Code, I don't get any error. Here's the code
const validWorkAddresses = workAddresses.filter((item) => !!item)
try {
const response = await triggerCreateRoute({
year,
createRouteInput: {
homeAddress,
workAddresses: validWorkAddresses,
selectedRoute,
overrideRoundtripDistanceKm,
suggestionId: routeData.suggestionId,
routeId,
},
}).unwrap()
setIsShowingEditDialog(false)
handleRouteResponse(response, 'DUPLICATE')
} catch (e) {}
workAddresses is of type DawaAddress | undefined)[] and updateRouteInput.workAddresses is of type DawaAddress[]
VS Code seems to understand that by running const validWorkAddresses = workAddresses.filter((item) => !!item) the list will not contain undefined elements.
Can I tweak tsc to get it?