jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.22k stars 348 forks source link

Error with DBSchema #220

Closed danieleguglietti closed 3 years ago

danieleguglietti commented 3 years ago

Hello everyone! I was trying the lib and using schemas for DB typing following the reference. The error occurs when I try to create the "connection" to the DB and create a store, the type the "createObjectStore" function expect is "never" when my interface extends DBSchema. After a deep look, I noticed that the "KnowKeys" type excludes the string type and that's ok because we want the keys' names as type, but the interface DBSchema declares its keys as a string and making it impossible to take keys names as type... In the reference, in the "Typescript" section it extends the interface to DBSchema, which is wrong causing the error mentioned above. Am I doing wrong/have I missed something in the reference? Or this is actually a project error?

jakearchibald commented 3 years ago

Can you provide some code showing the issue?

danieleguglietti commented 3 years ago

immagine This is the schema immagine And this is the error I mentioned, since DBSchema's key are marked as string

jakearchibald commented 3 years ago

Can you copy and paste the code so I don't have to type it out myself?

danieleguglietti commented 3 years ago

https://pastebin.com/JHE80WZB

jakearchibald commented 3 years ago

You example code works fine on the TypeScript playground.

I'm happy to help, but you must create a reduced example of the problem. I'll reopen this if you do that.