question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lib.dom.d.ts: IDBKeyPath defined as string instead of string|string[].

See original GitHub issue

TypeScript Version: 2.1.6

Code

    let request = window.indexedDB.open('database', /*version=*/1);

    request.onsuccess = (event: Event) => {
      let db = (event.target as IDBOpenDBRequest).result as IDBDatabase;
      db.createObjectStore('employees', {
        keyPath: ['company_id', 'employee_id']
      });
    };

Expected behavior: Compiles.

Actual behavior:

test_db.ts(26,35): error TS2345: Argument of type '{ keyPath: string[]; }' is not assignable to parameter of type 'IDBObjectStoreParameters | undefined'.
  Type '{ keyPath: string[]; }' is not assignable to type 'IDBObjectStoreParameters'.
    Types of property 'keyPath' are incompatible.
      Type 'string[]' is not assignable to type 'string | undefined'.
        Type 'string[]' is not assignable to type 'string'.

Notes: IndexedDB definition of keypath: https://www.w3.org/TR/IndexedDB/#dfn-key-path

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rtmcommented, Mar 4, 2017

IDBObjectStore.getAll() is also not defined.

0reactions
mhegazycommented, Feb 27, 2017

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

lib.dom.d.ts: IDBKeyPath defined as string instead of string
TypeScript Version: 2.1.6 Code let request = window.indexedDB.open('database', /*version=*/1); request.onsuccess = (event: Event) => { let ...
Read more >
IDBObjectStore | typescript - v3.7.7 - Microsoft Open Source
Returns the key path of the store, or null if none. name. name: string. Defined in node_modules/typedoc/node_modules/ ...
Read more >
node_modules/typescript/lib/lib.dom.d.ts - Google Git
interface IDBObjectStoreParameters {. autoIncrement?: boolean;. keyPath?: string | string[] | null;. } interface IDBVersionChangeEventInit extends EventInit ...
Read more >
Indexed Database API 3.0 - W3C
A key path is a string or list of strings that defines how to extract a key from a value. A valid key...
Read more >
https://raw.githubusercontent.com/Microsoft/TypeSc...
Instead, if it is negative, NaN, or not a number, the resulting ... BufferSource; } interface RsaOtherPrimesInfo { d?: string; r?: string; t?:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found