gpt4 book ai didi

typescript - IDBObjectStore.getAll() 缺少类型定义?

转载 作者:搜寻专家 更新时间:2023-10-30 22:00:52 31 4
gpt4 key购买 nike

IDBObjectStore有一个方法 getAll() .

但是,TypeScript 报告没有这样的方法。 lib.d.ts 中的相关部分是:

interface IDBObjectStore {
readonly indexNames: DOMStringList;
keyPath: string | string[];
readonly name: string;
readonly transaction: IDBTransaction;
autoIncrement: boolean;
add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest;
clear(): IDBRequest;
count(key?: IDBKeyRange | IDBValidKey): IDBRequest;
createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex;
delete(key: IDBKeyRange | IDBValidKey): IDBRequest;
deleteIndex(indexName: string): void;
get(key: any): IDBRequest;
index(name: string): IDBIndex;
openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest;
put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest;
}

看不到 getAll()。这是类型定义中的错误吗?

使用 TS 2.2.1,目标为 es6。

最佳答案

作为解决方法,您可以在您的项目中创建一个类型定义文件,如 indexeddb.d.ts,内容如下:

interface IDBObjectStore {
getAll(): IDBRequest;
}

关于typescript - IDBObjectStore.getAll() 缺少类型定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42592104/

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