Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMKVStorageWrapper needs to handle null OR TypeScript typings are wrong #428

Closed
hitsthings opened this issue Jul 20, 2021 · 2 comments
Closed

Comments

@hitsthings
Copy link

await persistCache({
    cache,
    storage: new MMKVStorageWrapper(apolloCacheStorage),
});

The above shows an error on the storage property:

Type 'MMKVStorageWrapper' 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'.ts(2322)

I believe MMKV can indeed only handle strings using setItem. Not sure the semantics of null here.

@wodCZ
Copy link
Collaborator

wodCZ commented Jul 20, 2021

Hi @hitsthings, thanks for reporting.

This is an issue introduced in v0.10.0 and is already discussed in #426.

The problem is in type definitions that were generalised in #420, the storage wrapper should work without a problem.
You can @ts-ignore this at the moment, and subscribe to #426 for updates.

@hitsthings
Copy link
Author

Ah, sounds good, thank you! Good to know it's just the TS.

Will close this then to be tracked in #426 . Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants