我正在尝试为我当前的项目构建一些基类。目前我收到此编译器错误:
类型“IConcreteScope”不满足类型参数“TScope extends IEntityScope”的约束“IEntityScope”。
当我尝试运行此代码时:
// scope
export interface IScope {
context: any;
}
export class ContextBase<TScope extends IScope> {
scope: TScope;
}
// entity
export interface IEntity {
id: string;
}
export interface IEntityScope<TEntity extends IEntity> extends IScope {
entity: TEntity;
}
export class EntityContextBase<TEntity extends IEntity, TScope extends IEntityScope<TEntity>> {
operation(entity: TEntity) {...}
}
// concrete
export interface IConcreteEntity extends IEntity {
name: string;
}
export interface IConcreteScope extends IEntityScope<IConcreteEntity> {
someprop: boolean;
}
// this is the problem: EntityContextBase<IConcreteEntity,IConcreteScope>
export class ConcretContext extends EntityContextBase<IConcreteEntity,IConcreteScope> {
}
这里是 TypeScript 游乐场代码的链接
我究竟做错了什么?