Skip to content

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

Closed
@qchuchu

Description

@qchuchu

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?

  • Android
  • iOS
  • macOS
  • Windows
  • web

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

  • Create a node project with typescript 4.9.5 + async storage 1.17.11
  • Create a ts file with this content
  • See the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions