Skip to content

lib.dom.d.ts: IndexedDB typings: "IDBValidKey | IDBKeyRange" used instead of just "IDBValidKey" in several places #29070

Closed
microsoft/TypeScript-DOM-lib-generator
#630
@mikelehen

Description

@mikelehen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions