遵循Angular 2示例here。在运行tsc:{/ 1>时implements
之后可能出现错误
错误TS2315:类型'CanDeactivate'不是通用的。
import { Injectable } from '@angular/core';
import { CanDeactivate } from '@angular/router';
import { Observable } from 'rxjs/Observable';
export interface CanComponentDeactivate {
canDeactivate: () => boolean | Observable<boolean>;
}
@Injectable()
export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
canDeactivate(component: CanComponentDeactivate): Observable<boolean> | boolean {
return component.canDeactivate ? component.canDeactivate() : true;
}
}
这让我感到困惑,因为已经声明了界面。为什么我在那里看到错误?