Consider the following method:
private handleError<T> (operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
this.log('${operation} failed: ${error.message}');
return of(result as T);
};
}
Considering that the implementation of a generic type implies a return of the same type of generic T
, why the need to use result as T
, where result
will always be T
? >
return of(result as T);