I have two classes that inherit from the same superclass:
class Vehicle {} class Bus extends Vehicle {} class Truck extends Vehicle {}
Let have two typed arrays:
var buses : Bus[]; var trucks : Truck[];
and a function that takes an array of type superclass.
function checkOil(vehicles : Vehicle[]) {}
I can transfer to an array of buses or an array of trucks, but I cannot combine them and transfer them together:
function checkOil(buses.concat(trucks)); //error TS2082: Supplied parameters do not match any signature of call target: Types of property 'pop' of types 'Bus[]' and 'Track[]' are incompatible:
How to combine these arrays?
EDIT: TypeScript Playground
source share