Redux-persist: Type mismatch: Property '_persist' is missing in type 'State'.

Created on 22 Jan 2018  路  4Comments  路  Source: rt2zz/redux-persist

The typing for PersistedState is not accurate in my opinion, which leads to this error:

ERROR in [at-loader] ./src/index.tsx:36:5 
    TS2345: Argument of type 'Reducer<(State & void) | (State & { _persist: PersistState; })>' is not assignable to parameter of type 'Reducer<State>'.
  Types of parameters 'state' and 'state' are incompatible.
    Type 'State' is not assignable to type '(State & void) | (State & { _persist: PersistState; })'.
      Type 'State' is not assignable to type 'State & { _persist: PersistState; }'.
        Type 'State' is not assignable to type '{ _persist: PersistState; }'.
          Property '_persist' is missing in type 'State'.
[...]
    export interface PersistState { version: number; rehydrated: boolean; }
    export type PersistedState = { _persist: PersistState } | void;

    export interface PersistConfig {
[...]

I will create a pull-request.

Most helpful comment

Reproduced with redux-persist: 6.0.0. @rt2zz could this bug appear again?

My root/index.ts file:

image

Fixed by wrapping State type in CombinedState of redux

image

React native info:

System:
    OS: macOS Mojave 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Memory: 387.30 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.17.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  Languages:
    Java: javac 13 - /usr/bin/javac
    Python: 2.7.10 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.0 => 0.63.0 
  npmGlobalPackages:
    *react-native*: Not Found

All 4 comments

Was fixed with #725.

just published v5.9.1 馃憤 ty

Reproduced with redux-persist: 6.0.0. @rt2zz could this bug appear again?

My root/index.ts file:

image

Fixed by wrapping State type in CombinedState of redux

image

React native info:

System:
    OS: macOS Mojave 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
    Memory: 387.30 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.17.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  Languages:
    Java: javac 13 - /usr/bin/javac
    Python: 2.7.10 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.0 => 0.63.0 
  npmGlobalPackages:
    *react-native*: Not Found
Was this page helpful?
0 / 5 - 0 ratings