Description
TypeScript Version: 3.3.0
Search Terms: IDBValidKey, IDBKeyRange
Code
let x: IDBCursor;
const y: IDBValidKey = x.primaryKey;
Expected behavior:
No compile errors.
Actual behavior:
typescript-indexeddb-bug.ts:2:7 - error TS2322: Type 'string | number | Date | ArrayBuffer | ArrayBufferView | IDBArrayKey | IDBKeyRange' is not assignable to type 'IDBValidKey'.
Type 'IDBKeyRange' is not assignable to type 'IDBValidKey'.
Type 'IDBKeyRange' is missing the following properties from type 'IDBArrayKey': length, pop, push, concat, and 16 more.
2 const y: IDBValidKey = x.primaryKey;
Related Issues:
Doing a manual audit of lib.dom.d.ts, the following properties and methods contain incorrect usages of IDBValidKey | IDBKeyRange
and should just be IDBValidKey
instead:
- IDBCursor.key
- IDBCursor.primaryKey
- IDBCursor.continue()
- IDBCursor.continuePrimaryKey() [both parameters]
- IDBObjectStore.add()
- IDBObjectStore.put()
I would be happy to send a PR, but my impression is that these typing files are auto-generated.