title: RXJS 6: new version of HttpInterceptor
body: <p>I am in the process of adding <code>rxjs_compat</code> to my project in order to move to v6 of libraries.</p>
  
  <p>However the existing <code>HttpInterceptor</code> for global error handling no longer compiles. Not sure where to go with it. Tried all sorts. Getting type mismatches with everything tried.</p>
  
  <pre><code>import { Injectable } from "@angular/core";
  import {
    HttpEvent,
    HttpInterceptor,
    HttpHandler,
    HttpRequest,
    HttpResponse,
    HttpErrorResponse
  } from "@angular/common/http";
  import { Observable, of, empty } from "rxjs";
  import { ToastrService } from "ngx-toastr";
  import { environment } from "../../environments/environment";
  import { catchError, map } from "rxjs/operators";
  
  @Injectable()
  export class HttpErrorInterceptor implements HttpInterceptor {
    constructor(private toastr: ToastrService) {}
    intercept(
      request: HttpRequest&lt;any&gt;,
      next: HttpHandler
    ): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      return next.handle(request).pipe(
        catchError(err =&gt; of(HttpErrorResponse)),
        map(err =&gt; {
          let message: string;
           this.toastr.error(`${message}`, "Application Error");
          return Observable.empty&lt;HttpEvent&lt;any&gt;&gt;();
        })
      );
    }
  }
  </code></pre>
  
  <blockquote>
    <p>src/app/shared/http-error-interceptor.ts(26,27): error TS2339:
    Property 'empty' does not exist on type 'typeof Observable'.</p>
  </blockquote>
  
  <p><code>empty</code> is now a constant, but doesn't accept a type, so that does not work either. Also could not find much in <a href="https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#dep-methods" rel="noreferrer">the upgrade notes</a> </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>although interestingly this compiles:</p>
  
  <pre><code>return Observable.of&lt;HttpEvent&lt;any&gt;&gt;();
  </code></pre>