diff --git a/src/matrix/storage/idb/QueryTarget.ts b/src/matrix/storage/idb/QueryTarget.ts index bb02b990..88304db2 100644 --- a/src/matrix/storage/idb/QueryTarget.ts +++ b/src/matrix/storage/idb/QueryTarget.ts @@ -18,15 +18,15 @@ import {iterateCursor, reqAsPromise} from "./utils"; type Reducer = (acc: B, val: A) => B -type IDBQuery = IDBValidKey | IDBKeyRange | undefined +export type IDBQuery = IDBValidKey | IDBKeyRange | undefined | null interface QueryTargetInterface { - openCursor: (range?: IDBQuery | null , direction?: IDBCursorDirection) => IDBRequest; - openKeyCursor: (range?: IDBQuery, direction?: IDBCursorDirection) => IDBRequest; + openCursor: (range?: IDBQuery, direction?: IDBCursorDirection | undefined) => IDBRequest; + openKeyCursor: (range?: IDBQuery, direction?: IDBCursorDirection | undefined) => IDBRequest; supports: (method: string) => boolean; keyPath: string | string[]; - get: (key: IDBQuery) => IDBRequest; - getKey: (key: IDBQuery) => IDBRequest; + get: (key: IDBValidKey | IDBKeyRange) => IDBRequest; + getKey: (key: IDBValidKey | IDBKeyRange) => IDBRequest; } export class QueryTarget { @@ -52,11 +52,11 @@ export class QueryTarget { return this._target.supports(methodName); } - get(key: IDBQuery): Promise { + get(key: IDBValidKey | IDBKeyRange): Promise { return reqAsPromise(this._target.get(key)); } - getKey(key: IDBQuery): Promise { + getKey(key: IDBValidKey | IDBKeyRange): Promise { if (this._target.supports("getKey")) { return reqAsPromise(this._target.getKey(key)); } else { diff --git a/src/matrix/storage/idb/Store.ts b/src/matrix/storage/idb/Store.ts index 585b3948..890785bd 100644 --- a/src/matrix/storage/idb/Store.ts +++ b/src/matrix/storage/idb/Store.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {QueryTarget} from "./QueryTarget"; +import {QueryTarget, IDBQuery} from "./QueryTarget"; import {IDBRequestAttemptError} from "./error"; import {reqAsPromise} from "./utils"; import {Transaction} from "./Transaction"; @@ -50,7 +50,7 @@ class QueryTargetWrapper { return !!this._qt[methodName]; } - openKeyCursor(range?: IDBKeyRange, direction?: IDBCursorDirection): IDBRequest { + openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest { try { // not supported on Edge 15 if (!this._qt.openKeyCursor) { @@ -64,7 +64,7 @@ class QueryTargetWrapper { } } - openCursor(range?: IDBKeyRange, direction?: IDBCursorDirection): IDBRequest { + openCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest { try { LOG_REQUESTS && logRequest("openCursor", [], this._qt); return this._qt.openCursor(range, direction) @@ -73,7 +73,7 @@ class QueryTargetWrapper { } } - put(item: T, key?: IDBValidKey): IDBRequest { + put(item: T, key?: IDBValidKey | undefined): IDBRequest { try { LOG_REQUESTS && logRequest("put", [item, key], this._qt); return this._qtStore.put(item, key); @@ -82,7 +82,7 @@ class QueryTargetWrapper { } } - add(item: T, key?: IDBValidKey): IDBRequest { + add(item: T, key?: IDBValidKey | undefined): IDBRequest { try { LOG_REQUESTS && logRequest("add", [item, key], this._qt); return this._qtStore.add(item, key); @@ -91,7 +91,7 @@ class QueryTargetWrapper { } } - get(key: IDBValidKey): IDBRequest { + get(key: IDBValidKey | IDBKeyRange): IDBRequest { try { LOG_REQUESTS && logRequest("get", [key], this._qt); return this._qt.get(key); @@ -100,7 +100,7 @@ class QueryTargetWrapper { } } - getKey(key: IDBValidKey): IDBRequest { + getKey(key: IDBValidKey | IDBKeyRange): IDBRequest { try { LOG_REQUESTS && logRequest("getKey", [key], this._qt); return this._qt.getKey(key)