angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 232 forks source link

Class 'HttpClientBackendService' incorrectly implements interface 'HttpBackend'. #180

Closed IgorMinar closed 6 years ago

IgorMinar commented 6 years ago

When compiling angular.io examples after update to rxjs v6 I'm getting the following error:

node_modules/angular-in-memory-web-api/http-client-backend.service.d.ts(32,22): error TS2420: Class 'HttpClientBackendService' incorrectly implements interface 'HttpBackend'.
  Types of property 'handle' are incompatible.
    Type '(req: HttpRequest<any>) => Observable<HttpResponse<any>>' is not assignable to type '(req: HttpRequest<any>) => Observable<HttpEvent<any>>'.
      Type 'Observable<HttpResponse<any>>' is not assignable to type 'Observable<HttpEvent<any>>'.
        Property 'source' is protected but type 'Observable<T>' is not a class derived from 'Observable<T>'.

I haven't investigated why this error is surfaced only now, but it does seem that the interface is incorrectly implemented. See:

https://github.com/angular/in-memory-web-api/blob/748891871fdb61d071f9dbf57fa8174924cebfb7/src/in-mem/http-client-backend.service.ts#L64

Which returns an Observable<HttpResponse<any>> and not it's super class Observable<HttpEvent<any>>.

Found in version: 0.5.3

Workaround: disable typecheck of 3rd party code by setting "skipLibCheck": true in tsconfig.json.

wardbell commented 6 years ago

Fixing in addendum to PR #182