-
Notifications
You must be signed in to change notification settings - Fork 1
Description
In `src/storage.ts:9-11`:
export const storage = createStorage({
driver: memoryDriver()
}) as unknown as Storage & { options?: { prefix?: string } }This casts the unstorage instance to the Web API `Storage` interface (which has `getItem(key): string | null`, `setItem(key, value): void`, etc.) rather than the unstorage `Storage` type (which has `getItem(key): Promise`, `setItem(key, value): Promise`, etc.).
It works at runtime because the code `await`s every call, but TypeScript thinks the return types are synchronous. Any future refactor that trusts the types could silently drop awaits and break.
The `initStorage` function also uses `Object.assign(storage, createStorage({...}))` to mutate the exported object in place, which is fragile — it copies own properties but doesn't update the prototype chain, so any method that lives on the prototype won't be replaced.
Typing it as `ReturnType` (or the unstorage `Storage` type) with an extended interface for `options` would fix the type mismatch without the double assertion.