Currently, I am developing an adapter for the HttpClient in Angular that requires two different get functions - one for returning a Blob and another for returning a generic. However, when I try to execute this implementation, I encounter the following error:
Error TS2393: Duplicate function implementation.
get<T>(url: string, options?: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
context?: HttpContext;
observe?: 'body';
params?: HttpParams | {
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
};
reportProgress?: boolean;
responseType?: 'json';
withCredentials?: boolean;
}): Observable<T> {
return this.handleRequest(this.http.get<T>(url, options));
}
get(url: string, options: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe: 'response';
context?: HttpContext;
params?: HttpParams | {
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
};
reportProgress?: boolean;
responseType: 'blob';
withCredentials?: boolean;
}): Observable<HttpResponse<Blob>> {
return this.handleRequest(this.http.get(url, options));
}
It's perplexing to me that I'm receiving an error considering that the actual implementation of these get functions in the HttpClient class is very similar.