'Redux & TypeScript: Property 'X' is missing in type 'DefaultRootState' - but the property is declared in Interface

Here's my Interface which I'm using with mapStateToProps:

export interface IStore {
  cache?: any;
  dataManager?: IUR;
  userPrefs: IUP;
  fingerprintModal?: IfingerprintModal;
}

export interface IfingerprintModal {
  cbCancel: IFModalFn | null;
  cbTryAgain?: IFModalFn | null;
  error: null | string;
  success: boolean;
  visible: boolean;
}

Here's the mapStateToProps fn expression:

const mapStateToProps = (state: IStore) => ({
  store: {
    fingerprintModal: state.userPrefs.fingerprintModal,
  },
});

And here's the connect HOC:

export default connect<IStore,{}>(mapStateToProps, mapDispatchToProps)(FingerprintModal);

That's the error I'm seeing: enter image description here

I can get rid of the problem by:

export default connect<IStore>(mapStateToProps as any, mapDispatchToProps)(FingerprintModal);

But I am trying to find a generic solution to that



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source