skip to Main Content

Getting error message

Type 'AsyncStorageStatic' is missing the following properties from type 'IAsyncStorage<string, any>': store, size, getStorets(2739

I have followed the documentation for installation, however still errors.

2

Answers


  1. You can find the type you need in this file:

    ~/node_modules/keyvaluestorage/dist/cjs/react-native/types.d.ts
    

    Its content is:

    export declare namespace AsyncStorageTypes {
        type Entry<K = string, V = any> = [K, V | null];
        type Entries<K = string, V = any> = Array<Entry<K, V>>;
        type ErrBack<V = any> = (err: Error | null, val?: V | null) => {};
        type ArrErrBack<V = any> = (err: Array<Error> | null, val?: V) => {};
    }
    export declare abstract class IAsyncStorage<K = string, V = any> {
        abstract store: Map<K, V | null>;
        abstract size(): number;
        abstract getStore(): Map<K, V | null>;
        abstract getItem(k: K, cb?: AsyncStorageTypes.ErrBack<V>): Promise<V | null>;
        abstract setItem(k: K, v: V, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
        abstract removeItem(k: K, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
        abstract clear(cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
        abstract getAllKeys(cb?: AsyncStorageTypes.ErrBack<Array<K>>): Promise<Array<K>>;
        abstract multiGet(keys: Array<K>, cb?: AsyncStorageTypes.ErrBack<AsyncStorageTypes.Entries<K, V>>): Promise<AsyncStorageTypes.Entries<K, V>>;
        abstract multiSet(entries: AsyncStorageTypes.Entries<K, V>, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
        abstract multiRemove(keys: Array<K>, cb?: AsyncStorageTypes.ErrBack<V>): Promise<void>;
        abstract mergeItem(key: string, value: string, cb?: AsyncStorageTypes.ErrBack<string>): Promise<void>;
        abstract multiMerge(entries: AsyncStorageTypes.Entries<string, string>, cb?: AsyncStorageTypes.ArrErrBack<string>): Promise<void>;
        abstract flushGetRequests(): any;
    }
    

    Import or copy it in your code and then do something like:

    <WalletConnectProvider
      storageOptions={{
        asyncStorage: AsyncStorageStatic as unknown as IAsyncStorage,
      }}
    >
      <App/>
    </WalletConnectProvider>
    
    Login or Signup to reply.
  2. Sometimes you need restart your android emulator or stop it and start over freshly if it does not find the type or module after its Installation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search