1

我正在尝试为我当前的项目构建一些基类。目前我收到此编译器错误:

类型“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 游乐场代码的链接

我究竟做错了什么?

4

1 回答 1

1

代码很好;这是编译器中的一个错误。这在开发分支的最新源中编译没有错误。

于 2013-10-03T17:03:11.860 回答