So here's the scenario: I have an object of type 'any' and I want to assign it an object of type 'myResponse' as shown below.
public obj: any;
public set Result() {
obj = myResponse;
}
Now, in another function, I need to convert this generic 'any' type to my specific type - let's call it 'MyResponse'. Here's what I tried:
public myFunction(){
let x: MyResponse = (MyResponse) obj;
conosle.log(x.somePropoerty);
}
I explored various methods like using angular brackets for casting and Object.assign, but unfortunately, they didn't work in this case. In addition, just to give you a clearer picture, here is how the 'MyResponse' class looks like:
export class MyResponse{
public property1: string;
public property2: number;
//some other code
}