【发布时间】:2021-07-01 03:04:28
【问题描述】:
我对泛型类型有疑问。它的简化版是这样的。
import { Document, Model } from 'mongoose';
interface Base {
age: number;
}
class Test<T extends Base> {
private t: Model<T & Document>
}
这部分 Model<T & Document> 出现错误,上面写着:
Type 'T & Document<any, {}>' does not satisfy the constraint 'Document<any, {}>'
有人知道吗?
【问题讨论】:
标签: typescript mongoose typescript-typings typescript-generics