My service features a basic structure:
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class AddressService {
constructor(private http: Http) { }
getAnything = (): Observable<Response> => {
return this.http.get('https://my_api.com')
.map(this.handleSuccess)
.catch(this.handleError);
}
handleError = (error: Response): Observable<Response> => {
return Observable.throw(error || 'Server Error');
}
handleSuccess = (response: Response): Observable<Response> => {
let body;
if (response.text()) {
body = response.json();
}
return body || {};
}
}
Everything was functioning flawlessly, up until the upgrade of Typescript from version 2.3.4 to 2.4.1.
Post-upgrade, I encounter a puzzling error:
Type 'Observable<Response | Observable<Response>>' is not assignable to type 'Observable<Response>'
What's causing this issue? What modifications in TS 2.4.x have impacted the functionality of my application?