But when filtering using any other method it does not give back the correct type
const myFilteredArray = myArray.filter(Number.isNaN)
// ^? (number | undefined)[]
// Below might be impossible, but would be sick if ts can do this
function myCustomFilter(input?: number) {
return input !== undefined
}
const myFilteredArray = myArray.filter(myCustomFilter)
// ^? (number | undefined)[]
I am not sure if any of this would even be possible.
Given the following array
I can do the following filter using
Boolean
But when filtering using any other method it does not give back the correct type