I hae a model of car imported into current component. Trying to declare an array of cars as a return type to one of the functions. But the compiler would not recognize the car array type. Can you please help ?
carcomponent.ts
import { Car } from '../models/car';
export class carComponent implements onInit {
public car : Car;
carsavailable(): Car[] { //delcaring Car[] is not recognized.
}
}
car.ts .......
export class Car {
name: string;
}
ERROR
The compiler underlines Car[] in red and says 'A function whose delcared type is neither 'void' nor 'any' must return a value.
Do I have to plug in car somewhere or change return type declaration way.