I am creating a project using Angular, I started the project using angular-cli, and when I try to start ng build --prod, I keep getting this error:
The 'description' property does not exist for type Object
The code generating this error is as follows:
export class AppComponent {
product: Object = {};
constructor(
private store: StoreService,
private request: RequestService,
) {
this.product = this.request.getProduct(_id);
}
}
<p>{{product.description}}</p>
I read some content about this, and the error is that I use a type definition to define a product as an object, but I do not pass any property definition.
I know that I can define the interface, as I do with arrays, but I could not do this. I donโt know if I am defining this incorrectly, this is how I tried:
export interface ProductInterface {
id: Number;
description: String;
title: String;
}
product: Object<ProductInterface> = {};
But it also gives me errors. What do I need to do to avoid this?