I have an API endpoint that returns the following response:
{
"response": [ { "label": "mylabel", "name": "myname" } ],
"status": 200
}
At first I created an interface that matches this exact structure, but then, just to test, I changed it to this:
export interface ListResponse {
response: number;
status: boolean;
}
this.http.get<ListResponse>('/api/list.php').subscribe(data => {
console.log(data.response)
console.log(data.status)
});
I was expecting to get a typescript error since the response clearly doesn't match the interface property types, but I was able to access the fields as usual. What about type safety, isn't it a problem?