typescript - 类型 'value' 上不存在属性 'IDBCursor'

标签 typescript indexeddb typescript-typings

似乎 typescript 类型不知道 DBCursor 接口(interface)上的 value 属性。

let cursor: IDBCursor;
cursor.value

最佳答案

IDBCursor 接口(interface)没有 value 属性。您应该使用 IDBCursorWithValue interface ,它继承自IDBCursor

这段代码编译没有错误:

let cursor: IDBCursorWithValue;
cursor.value;

关于typescript - 类型 'value' 上不存在属性 'IDBCursor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52524921/

相关文章:

带有自定义 const 枚举的 Typescript 定义

typescript - 如何获取 expo-sqlite 的类型?

angular - 由于 "Value below was evaluated just now"无法获取数据

typescript - 如何在 typescript 中的 forEach 下定义类型?

html - 如何在 HTML5 Indexed Db 中使用连接?

internet-explorer - IndexedDB getAllKeys() polyfill 或类似的 IE

angular-cli - 带有 RxDB(idb 适配器)的 Angular 5 抛出未捕获的类型错误 : winningRev is not a function error when creating database

TypeScript:为什么 `Function` 不能分配给 `(...args: any[]) => any` ?

javascript - 将类实例作为函数调用 (JS/TS)

typescript - 如何将 GraphQL 与 TypeScript 和 graphql-code-generator 生成的类型一起使用?