How to cast object in object into Angular Class (Type)
Possible answer
export interface Category {
name: string;
prop: string;
}
export class Post {
category: Category[];
constructor(obj: any) {
this.category = obj.category as Category[];
}
}
`
The keyword as
allowed me to properly cast my object to desired class and fixed the error ´TS2322: Type '{}' is not assignable to type ...´. Thanks!