Why ListResult results values are typed as object

Hi,

While working with storage.query(), we noticed the getMany() function returns ListResult which in turn contains the Result interface. The latter is typed as:

export interface Result {
    key: string;
    value: object;
}

My question is: Why the value here is typed as object although in the storage.set() function is typed any?

This caused issues because in our case we were storing strings and we got type errors while using the value as string. We had to do some typescript workarounds to get over this:

const value = result.value as unknown as string;

I know this solution is working, but we would prefer a better handling of typescript types like using Generics or providing all the supported types as union in cases of set, get, and getMany.

Regards,
Ismail

1 Like