导出声明类对成员错误的不兼容替代Angular

时间:2018-09-18 19:20:37

标签: angular typescript webstorm

所以我有这个课:

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
  }
}
  • 它们都是Angular的相同版本。

0 个答案:

没有答案