jakearchibald / idb

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

Cannot open a transaction with all stores #234

Closed tomasreimers closed 3 years ago

tomasreimers commented 3 years ago

Hi,

I am trying to open a transaction that has access to all stores. MDN recommends doing this by:

var transaction = db.transaction(db.objectStoreNames);

(https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/transaction)

When I attempt to do this with idb, I get the typescript error:

No overload matches this call.
  Overload 1 of 2, '(storeNames: string, mode?: "readonly" | undefined, options?: IDBTransactionOptions | undefined): IDBPTransaction<unknown, [string], "readonly">', gave the following error.
Argument of type 'TypedDOMStringList<string>' is not assignable to parameter of type 'string'.
  Overload 2 of 2, '(storeNames: string[], mode?: "readonly" | undefined, options?: IDBTransactionOptions | undefined): IDBPTransaction<unknown, string[], "readonly">', gave the following error.
    Argument of type 'TypedDOMStringList<string>' is not assignable to parameter of type 'string[]'.
      Type 'TypedDOMStringList<string>' is missing the following properties from type 'string[]': pop, push, concat, join, and 26 more.

I'm fairly certain we can fix this by adding a third overload to transaction (happy to write that PR if you want), but wanted to check if this was intentional before throwing up a fix!

Thanks, Tomas

jakearchibald commented 3 years ago

Thanks for reporting this! I've changed the type to ArrayLike.

Fixed in e052a026d307d6524d5999ebd1806e77e0b8458c and published as 6.1.3.