如何使用扩展特定对象的泛型为状态创建接口?

How do make an interface for a state using generics which extend a certain object?

我的状态界面在这里。

export interface IState <T extends CashflowObject> {
    cashflowToPost?: T;
    cashflowList: T[];
}

我想将其用于我的摘要 class:

export default abstract class CashflowListView<T> extends React.Component<{}, IState<T>> 

然后我想指定我将为实现 CashflowListView 的其他 classes 使用什么类型的 cashflowobject class:

export default class AssetList extends CashflowListView<Asset> 

这是我的对象结构:

export interface CashflowObject {
    id: number;
    name: string;
    value: number;
    taxable: boolean;
}

export interface AssetLiability extends CashflowObject {
    interest: number;
}
export interface Liability extends AssetLiability{}
export interface Asset extends AssetLiability{}

但是我打字稿在以下部分抱怨说:

export default abstract class CashflowListView<T> extends React.Component<{}, IState<T>> 

T at React.Component<{}, IState<T>> 不扩展 Cashflow 对象,这是有道理的....但是制作 T 类型的 cashflow 会使打字稿在其他领域抱怨,比如我在 AssetList Class 中的渲染函数:

    render() {
        return (
            <div className="cashflow-table">
                {this.state.cashflowList.map((asset: Asset) => <this.AssetEntry asset={asset} />)}
                <AssetPost listUpdateFunction={this.callApi.bind(this)}></AssetPost>
            </div>
        )
    }

但是我该如何写我想做的事情呢?

export default abstract class CashflowListView<T extends CashflowObject> extends React.Component<{}, IState<T>> 

cashflowlistview 泛型中的 T 也必须扩展 cashflowobject。现在很明显了。