⬅️ Execute Program Advanced TypeScript
Type predicates in filter
- if we
filter
an Array<string | number>
and just want to get the numbers out, the return type will still be (string | number)[]
- you can fix this with a type predicate e.g.
isNumber
- it does that by using generic constraints and function overloads