gpt4 book ai didi

javascript - 我如何创建对象

转载 作者:搜寻专家 更新时间:2023-10-30 21:50:10 26 4
gpt4 key购买 nike

<分区>

我有一些问题:

class Collection<T extends IModel> extends Event implements ICollection<T> {
constructor(array: any[] = []) {
super()
this._init(array)
}
private _init(array: any[]) {
array.forEach((object) => {
if (this._isModel(object)) {
return console.log("hey")
}
const model = new T(object)
})
}

字符串“const model = new T(object)”有错误:

error TS2693: 'T' only refers to a type, but is being used as a value here.

有人知道我如何创建新 T 吗?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com