'Typescript react-redux configuring store error

This is my code:

interface IState {
  userData: {
    name: string
    age: number
  }
  // companyData: {},
  // websiteData: {}
}
export const initialState: IState = {
  userData: {
    name: "Mark",
    age: 30
  }
  // companyData: {},
  // websiteData: {},
} 

const mainReducer = combineReducers({
  userData: userReducer
  // companyData: companyDataReducer,
  // websiteData: websiteDataReducer,
});

const configureStore = () =>
  createStore(
    mainReducer,
    initialState,
    composeWithDevTools(applyMiddleware(thunk))
  );

export default configureStore;

it generates this error which I do not understand:

Argument of type 'IState' is not assignable to parameter of type '{ userData?: { userData: any; } | undefined; }'. Types of property 'userData' are incompatible. Property 'userData' is missing in type '{ name: string; age: number; }' but required in type '{ userData: any; }'.



Solution 1:[1]

I had issues with my reducers, I was returning whole state instead of a slice of the state and that was messing everything up.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 mycodegoesKABOOM