'Return IDBTransaction in Typescript

I'm trying to write some functions that allow a user to build their own transaction with IndexedDB in Typescript.

Calling db.transction(...) returns an IDBPTransaction<...> which Typescript complains is private.

How can I return an IDBTransaction from a function in Typescript?



Solution 1:[1]

IDBPTransaction is actually a type from the idb NPM package, not from the native browser implementation.

In order to return an IDBTransaction you need to use the IndexedDB API directly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 oorst