function apply<T extends Fruit[] | Vegetable[]>(all: T): T {
return all.filter((x) => true);
}
So I want the parameter all to either be of type Fruit[] or Vegetable[], not (Fruit | Vegetable)[]. And I want the function to return the same type as all. I think this confuses TS or I'm the one getting confused.
I'm getting the error This expression is not callable. Each member of the union type '...' has signatures, but none of those signatures are compatible with each other..
Is there another way of doing this? Like overloading or something?