IndexedDB 在Typescript中返回IDBTransaction

wpcxdonn  于 2022-12-09  发布在  IndexedDB
关注(0)|答案(1)|浏览(201)

我正在尝试用Typescript编写一些函数,允许用户使用IndexedDB构建自己的事务。
调用db.transction(...)将返回一个IDBPTransaction<...>,Typescript将该IDBPTransaction<...>报告为私有。
如何从Typescript中的函数返回IDBTransaction

wz1wpwve

wz1wpwve1#

IDBPTransaction实际上是来自idb NPM包的类型,而不是来自本机浏览器实现的类型。
为了返回IDBTransaction,您需要直接使用IndexedDB API。

相关问题