react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.7k stars 466 forks source link

[JEST][DOCUMENTATION] export default from jest mock cause typescript check error #946

Closed qchuchu closed 1 year ago

qchuchu commented 1 year ago

What happened?

While trying to implement the jest integration during our test, following this : https://react-native-async-storage.github.io/async-storage/docs/advanced/jest/, we followed the first way to do :

export default from '@react-native-async-storage/async-storage/jest/async-storage-mock';

However, this triggers two Typescript error (ts(1005) & ts(2304) :

image image

We managed to make it work by making the following :

import AsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';

export default AsyncStorage;

We are using typescript 4.9.5 & @react-native-async-storage/async-storage 1.17.11

Maybe you could change the documentation ?

Thanks !

Version

1.17.11

What platforms are you seeing this issue on?

System Information

info Fetching system and libraries information...
System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 53.93 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.0 - ~/.nvm/versions/node/v18.14.0/bin/npm
    Watchman: 2023.02.20.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 16.0.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.3 => 0.71.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
info React Native v0.71.4 is now available (your project is running on v0.71.3).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.71.4
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.3
info For more info, check out "https://reactnative.dev/docs/upgrading".

Steps to Reproduce

qchuchu commented 1 year ago

@xiniria

github-actions[bot] commented 1 year ago

This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.

Adnan-Bacic commented 1 year ago

coincidentally, i also made an issue about this before: https://github.com/react-native-async-storage/async-storage/issues/895

AsyncStorageBot commented 1 year ago

:tada: This issue has been resolved in version 1.18.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: