Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot unwrap db #323

Open
retorquere opened this issue Sep 4, 2024 · 0 comments
Open

cannot unwrap db #323

retorquere opened this issue Sep 4, 2024 · 0 comments

Comments

@retorquere
Copy link

retorquere commented Sep 4, 2024

given this code

import { unwrap, openDB, DBSchema, IDBPDatabase } from 'idb'

interface Schema extends DBSchema {
  test: {
    value: number
    key: number
  }
}

async function main() {
  const db: IDBPDatabase<Schema> = await openDB('test', 1, {
    upgrade($db, oldVersion, newVersion, transaction, event) {
      $db.createObjectStore('test')
    },
  })

  unwrap(db).close()
}

during typescript compilation, I am getting

content/db/testidb.ts(17,10): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type 'IDBPDatabase<Schema>' is not assignable to parameter of type 'Promise<unknown>'.
      Type 'IDBPDatabase<Schema>' is missing the following properties from type 'Promise<unknown>': then, catch, finally, [Symbol.toStringTag]
content/db/testidb.ts(17,14): error TS2339: Property 'close' does not exist on type 'IDBCursorWithValue'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant