jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.22k stars 348 forks source link

Unwrap object store of readwrite transaction fails type check #240

Closed dansebcar closed 2 years ago

dansebcar commented 2 years ago

If I write:

const tx = db.transaction("mystore")
const store = unwrap(tx.store)

everything works as expected. If I instead write:

const tx = db.transaction("mystore", "readwrite")
const store = unwrap(tx.store)

then typescript complains that no overload matches the unwrap call. However, it works as expected at run-time. Since IDBPObjectStore is a generic type of four arguments, shouldn't wrap-idb-value.ts interface Unwrap contain:

(value: IDBPObjectStore<any, any, any, any>): IDBObjectStore;

instead of:

(value: IDBPObjectStore<any, any, any>): IDBObjectStore;
jakearchibald commented 2 years ago

Ohhh good catch! This was missed when readwrite became part of the types. It also impacts cursors.

jakearchibald commented 2 years ago

Published as 6.1.5