Here's my Interface which I'm using with mapStateToProps:
export interface IStore {
cache?: any;
dataManager?: IUR;
userPrefs: IUP;
IModal?: IfingerprintModal;
}
export interface IModal {
cbCancel: IFModalFn | null;
cbTryAgain?: IFModalFn | null;
error: null | string;
success: boolean;
visible: boolean;
}
Here's the mapStateToProps fn expression:
const mapStateToProps = (state: IStore) => ({
store: {
IModal: state.userPrefs.IModal,
},
});
And here's the connect HOC:
export default connect<IStore,{}>(mapStateToProps, mapDispatchToProps)(IModal);
I can get rid of the problem by:
export default connect<IStore>(mapStateToProps as any, mapDispatchToProps)(IModal);
But I am trying to find a generic solution to that
Just remove the type from the connect call and let typescript to handle it for you:
connect(mapStateToProps, mapDispatchToProps)(FingerprintModal);
Otherwise you would need to specify the full type:
connect<{store: IStore;}, {}, {}, IStore>(mapStateToProps, mapDispatchToProps)