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

问题描述 投票:2回答:2

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。

typescript indexeddb
2个回答
0
投票

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

interface IDBObjectStore {
    getAll(): IDBRequest;
}

0
投票

我认为这是打字稿中的一个错误,它已经修复了尝试使用它的新版本

https://github.com/Microsoft/TypeScript/issues/24724

© www.soinside.com 2019 - 2024. All rights reserved.