profile
viewpoint

Ask questionsLocalStorageWrapper broken on 0.10.0

Using the same code from the example:

https://github.com/apollographql/apollo-cache-persist/blob/7bcb322a32aafb088afcf2c21c1ebe793409d8e3/examples/web/src/index.tsx#L76-L83

And from the readme, upgrading to 0.10.0 without any code changes breaks the use of LocalStorageWrapper:

TS2322: Type 'LocalStorageWrapper' is not assignable to type 'PersistentStorage<PersistedData<NormalizedCacheObject>>'.
Types of property 'setItem' are incompatible.
Type '(key: string, value: string) => void | Promise<void>' is not assignable to type '(key: string, value: PersistedData<NormalizedCacheObject>) => void | Promise<void> | PersistedData<NormalizedCacheObject> | Promise<...>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'PersistedData<NormalizedCacheObject>' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.

The types don't seem to line up. I think the problem is that the type parameter for CachePersistor is in this case NormalizedCacheObject so the options are ApolloPersistOptions<NormalizedCacheObject> which would then expect storage: PersistentStorage<PersistedData<NormalizedCacheObject>>, whereas LocalStorageWrapper would provide PersistentStorage<string>.

By the way, it might be helpful to build the examples as part of CI to serve as a canary for when these things happen.

apollographql/apollo-cache-persist

Answer questions blaenk

No rush at all! I simply stuck with the previous version for now, just thought I'd make you all aware of this.

Thank you and enjoy your holiday!

useful!
source:https://uonfu.com/
Github User Rank List