4

I'd like to use react-intl-redux and redux-form in my react app but I have a trouble doing the right thing while using combineReducers. I've tried many things but still couldn't figure it out.

react-intl-redux

import { combineReducers } from "redux";
import { intlReducer, IntlState } from "react-intl-redux";

export interface IAppState {
  intl: IntlState;
}

export default combineReducers<IAppState>({
  intl: intlReducer
});

[ts] Argument of type '{ intl: (state: IntlState, action: IntlAction) => IntlState; }' is not assignable to parameter of type 'ReducersMapObject'. Types of property 'intl' are incompatible. Type '(state: IntlState, action: IntlAction) => IntlState' is not assignable to type 'Reducer'. Types of parameters 'state' and 'state' are incompatible. Type 'IntlState | undefined' is not assignable to type 'IntlState'. Type 'undefined' is not assignable to type 'IntlState'. (alias) function intlReducer(state: IntlState, action: IntlAction): IntlState import intlReducer

redux-form

import { combineReducers } from "redux";
import { reducer as formReducer, FormState } from "redux-form";

export interface IAppState {
  form: FormState;
}

export default combineReducers<IAppState>({
  form: formReducer
});

[ts] Argument of type '{ form: FormReducer; }' is not assignable to parameter of type 'ReducersMapObject'. Types of property 'form' are incompatible. Type 'FormReducer' is not assignable to type 'Reducer'. Types of parameters 'state' and 'state' are incompatible. Type 'FormState | undefined' is not assignable to type 'FormStateMap'. Type 'undefined' is not assignable to type 'FormStateMap'. (alias) const formReducer: FormReducer import formReducer

Mehmet N. Yarar
  • 576
  • 9
  • 17
  • Possible duplicate of [CombineReducers with Typescript returns error "Argument of type is not assignable to parameter of type 'ReducersMapObject'"](https://stackoverflow.com/questions/47266283/combinereducers-with-typescript-returns-error-argument-of-type-is-not-assignabl) – falinsky Jul 02 '18 at 08:28
  • I'm looking forward to see the typescript implementations of `react-intl-redux` and `redux-form` especially. – Mehmet N. Yarar Jul 02 '18 at 09:39
  • https://www.npmjs.com/package/@types/react-intl-redux and https://www.npmjs.com/package/@types/redux-form ? – falinsky Jul 02 '18 at 09:40
  • Thanks @falinsky, I have all that. But I'd like to see an example code because I'm newbie in TypeScript field and couldn't figure out how to implement these two libraries. I have no problem with implementing my own reducers tho'. – Mehmet N. Yarar Jul 02 '18 at 09:48
  • did u solve the problem? – funky-nd Jul 11 '18 at 10:48
  • @funky-nd I switched to Flow for now :) I'll get back to TS when I have time. – Mehmet N. Yarar Jul 16 '18 at 16:42

1 Answers1

3

Try FormStateMap instead of FormState.

funky-nd
  • 637
  • 1
  • 9
  • 25