如何解决如何运行泛型类型的静态方法?
{name: "widget",date: "2020-12-12T14:00:00.000Z",description: "widget_2",value: 20}
import Dexie from "dexie";
interface IItem {
name?: string;
date?: Date;
description?: string;
value?: number;
}
class ItemDatabase extends Dexie {
items: Dexie.Table<IItem,[string,Date]>; // <<<
constructor() {
super("SO_64210806");
this.version(1).stores({
items: "[name+date]" // <<<
});
}
}
(async () => {
const db = new ItemDatabase();
await db.items.bulkPut([
{
name: "widget",date: new Date("2020-12-11T13:00:00.000Z"),description: "widget_1",value: 10
},{
name: "widget",date: new Date("2020-12-12T14:00:00.000Z"),value: 20
}
]);
const w2 = await db.items.get(["widget",new Date("2020-12-12T14:00:00.000Z")]); // <<<
console.log(w2);
})();
不起作用,因为 T 没有函数 work。为什么它没有?如何将 T 更改为可以运行函数的类型?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。