所以我有这个课:
import { HttpRequest, HttpErrorResponse, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
export declare class CommonHttpInterceptor implements HttpInterceptor {
constructor();
intercept(request: HttpRequest < any > , next: HttpHandler):
Observable < HttpEvent < any >> ;
protected _handleError(request: HttpRequest < any > ): (err: any) => void;
protected _handleUnknownResponse(err: HttpErrorResponse, request: HttpRequest < any > ): void;
protected _handleDefaultException(errorResponse: HttpErrorResponse): void;
protected _handleInvalidResponse(errorResponse: HttpErrorResponse): void;
protected _publishException(message: string, title ? : string): void;
}
当我尝试在另一个类上使用它时,出现构建错误& WebStorm抱怨说:
成员的不兼容替代
import {Injectable} from '@angular/core';
import {CommonHttpInterceptor} from 'that class above';
import {HttpErrorResponse} from '@angular/common/http';
@Injectable()
export class positionDataHttpInterceptor extends CommonHttpInterceptor {
constructor() {
super();
}
protected _handleDefaultException(errorResponse: HttpErrorResponse): void {
//some code
}
}