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

时间:2017-03-04 04:30:40

标签: typescript indexeddb

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。

2 个答案:

答案 0 :(得分:0)

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

interface IDBObjectStore {
    getAll(): IDBRequest;
}

答案 1 :(得分:0)

我认为这是打字稿中的错误,并且已经修复 尝试使用更新的版本

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