I'm building a project using Angular, I started the project using angular-cli and when I try to run ng build --prod
i keep getting this error:
Property 'description' does not exist on type Object
The code generating this error is the following:
export class AppComponent {
product: Object = {};
constructor(
private store: StoreService,
private request: RequestService,
) {
this.product = this.request.getProduct(_id);
}
}
<p>{{product.description}}</p>
I was reading some content about this and the error is because I'm using type definition to define product as Object, but I'm not passing any property definition.
I know I could define an Interface, like I do with arrays, but I wasn't able to do it. I don't know if I'm defining it wrong, 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?