jakearchibald / idb

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

Change default type from `void` to `unknown` #85

Closed NotWoods closed 5 years ago

NotWoods commented 5 years ago

Feedback for #84

void feels like a weird type to use to represent an unknown schema. More notably, it makes casting very difficult:

const openPromise = wrap(request) as unknown as Promise<IDBPDatabase<DBTypes>>;

unknown is better suited for an unknown type, and lets you cast easily:

const openPromise = wrap(request) as Promise<IDBPDatabase<DBTypes>>;

unknown does not extend DBScehma so the various conditional types still work.

jakearchibald commented 5 years ago

Brilliant, thank you!