If I use number instead for recordId (which seems more correct) I will have to use .toString() or equivalent to make Typescript happy:
const selectedKey: number = ...
await db.delete("records", selectedKey.toString())
However, this doesn't work. No key is deleted!
I'm assuming in runtime keys are just numbers and not converting them to strings work (even if Typescript thinks the keys are strings in transpile-time)
I perhaps found the answer myself, I used the type IDBKeyRange instead and both Typescript and runtime code seems to work. Not entirely sure yet that it's correct use of that type...
I'm having some issues with types when trying to delete records in an IndexedDB, when using typescript and idb.
I'm setting up a database with autoincremented keys like:
Typescript only accepts type string for keys as input to the delete function:
If I use number instead for recordId (which seems more correct) I will have to use .toString() or equivalent to make Typescript happy:
However, this doesn't work. No key is deleted!
I'm assuming in runtime keys are just numbers and not converting them to strings work (even if Typescript thinks the keys are strings in transpile-time)