When writing a http get request:
getProduct(path, opts?): Observable<Product> {
return this.http.get(path, opts?.httpParams).pipe(
map((res:IProduct) => new Product(res))
);
}
The Product class is constructed using an Interface:
export Interface IProduct {
productName:string;
productCode:string;
descr:string;
}
I initially assumed that when assigning an interface as type in map(), it would perform a check on the structure of the response. If any properties were missing, I expected to receive an error or some feedback. However, this was not the case, as it simply passed everything through in an attempt to create a Product Object.
Am I misunderstanding the proper usage of Interfaces? How can I ensure that the server response matches the required Interface structure?