I would like to declare an object that has the following structure
public car = {
price: 20000,
currency: EUR,
seller: null,
model: {
color: null,
type: null,
year: null
} as Array<object>
};
Then, when I work with this object, I have something like
public addProduct(typeId: number): void {
this.car.model.push({type: typeId});
}
The problem I am facing is when I defined the model object, as using as Array<object> generates something alone the lines
Type '{ color: null; type: null; year: null; }' cannot be converted to type 'object[]'. Property 'length' is missing in type '{ color: null; type: null; year: null; }
I couldn't find a proper why to define this. It was important to use push to generate an "empty" object to which I can add the attributes from the view.