When using angular HttpClient your request is automatically parsed as JSON (unless the request's response type is not set to handle different data type). As @Alexander Statoselsky said in the comment, you can set the type of your response, so TypeScript will now what data structure is returned from the backend.
search(query: string): Observable<SearchResult[]> {
const queryUrl = `${url}${params}`;
return this.http.get<CustomResultInterface[]>(queryUrl, {headers}).pipe(
// As HttpClient cares only about the structure, you still need to loop
// through the returned data and create a classes if you want the method to return
// a list of SearchResult classes.
// CustomResultInterface is your custom interface that carries only the structure of the response
map(results => results.map(result => new SearchResult(result)))
);
}
Also, when using queryParameters, you might want to take a look at HttpParams which you'd use as following example
search(query: string): Observable<SearchResult[]> {
const params = new HttpParams();
params.set('query', query);
return this.http.get<CustomResultInterface[]>(url, { params, headers }).pipe(
map(results => results.map(result => new SearchResult(result)))
);
}