virgil-e3kit-js icon indicating copy to clipboard operation
virgil-e3kit-js copied to clipboard

.AsyncStorageStatic is not assignable to type

Open rantwijk opened this issue 5 years ago • 4 comments

Describe the bug Version: "@virgilsecurity/e3kit": "^0.7.0-beta.2" Import: import { EThree } from '@virgilsecurity/e3kit-native'; After following the installation steps, a type error is shown related to AsyncStorage. When using AsyncStorage from react-native (deprecated), this error does not appear.

To Reproduce Steps to reproduce the behavior:

  1. Follow Virgil E3Kit SDK for React Native installation instructions.
  2. Try to use the example Usage code to initialize EThree using TypeScript.
  3. "EThree.initialize(getToken, { AsyncStorage })" will show a Type error.

Expected behavior No error.

Desktop (please complete the following information):

  • OS: OSX 10.14.6
  • Browser Chrome
  • Version 78

Smartphone (please complete the following information):

  • Device: iPhone 11 Pro Max Simulator
  • OS: 13.0
  • Browser Safari

Additional context Error: (property) EThreeNativeInitializeOptions.AsyncStorage: AsyncStorageStatic

Type 'import("@react-native-community/async-storage").AsyncStorageStatic' is not assignable to type 'import("/Users/x/x/x/x/mobile-app/node_modules/@virgilsecurity/e3kit-native/node_modules/@types/react-native/index").AsyncStorageStatic'. Types of property 'multiGet' are incompatible. Type '(keys: string[], callback?: ((errors?: Error[] | undefined, result?: [string, string | null][] | undefined) => void) | undefined) => Promise<[string, string | null][]>' is not assignable to type '(keys: string[], callback?: ((errors?: Error[] | undefined, result?: [string, string][] | undefined) => void) | undefined) => Promise<[string, string][]>'. Types of parameters 'callback' and 'callback' are incompatible. Types of parameters 'result' and 'result' are incompatible. Type '[string, string | null][] | undefined' is not assignable to type '[string, string][] | undefined'. Type '[string, string | null][]' is not assignable to type '[string, string][]'. Type '[string, string | null]' is not assignable to type '[string, string]'. Type 'string | null' is not assignable to type 'string'. Type 'null' is not assignable to type 'string'.ts(2322)

EThree.d.ts(5, 5): The expected type comes from property 'AsyncStorage' which is declared here on type 'EThreeNativeInitializeOptions'

rantwijk avatar Nov 25 '19 15:11 rantwijk

Hi @rantwijk ! It appears that typings for @react-native-community/async-storage and react-native are different 😔 We will get back to you as soon as we will fix it. For now, you can cast your storage to other type or use // @ts-disable comment.

snanovskyi avatar Nov 25 '19 16:11 snanovskyi

image

Same here!

hyochan avatar Feb 26 '20 13:02 hyochan

This even fails the testing build since the AsyncStorage is different. https://circleci.com/gh/dooboolab/hackatalk-mobile/504?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

hyochan avatar Feb 26 '20 14:02 hyochan

Hi @rantwijk ! It appears that typings for @react-native-community/async-storage and react-native are different 😔 We will get back to you as soon as we will fix it. For now, you can cast your storage to other type or use // @ts-disable comment.

bump, any plans to address this? still happening over a year later 😦

edwinckc avatar May 11 '21 02:05 edwinckc

Closing as outdated

rstp-god avatar Jan 12 '23 19:01 rstp-god

Still the same type bug for me with the following versions: "@storybook/react-native": "6.0.1-beta.7" "@react-native-async-storage/async-storage": "^1.17.10",

nzcodarnoc avatar Feb 16 '23 00:02 nzcodarnoc