react-localize-redux icon indicating copy to clipboard operation
react-localize-redux copied to clipboard

Type mismatch when using redux toolkit with Typescript

Open MagnusHopland opened this issue 3 years ago • 0 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior? When using configure store i get an error Types of parameters 'action' and 'action' are incompatible. Property 'payload' is missing in type 'AnyAction' but required in type 'BaseAction<string, InitializePayload & AddTranslationPayload & AddTranslationForLanguagePayload & SetActiveLanguagePayload>' When adding localize: localizeReducer to the store.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

import { configureStore} from '@reduxjs/toolkit'
import someSlice from './SomeStore'
import { localizeReducer } from 'react-localize-redux'

export default configureStore({
  reducer: {
    localize: localizeReducer,
    someStore: someSlice,
  },
  middleware: (getDefaultMiddleware) => getDefaultMiddleware({serializableCheck: {
    ignoredActions: ['@@localize/INITIALIZE'],
  }}),
})

Setting export function localizeReducer( state: LocalizeState | undefined, action: AnyAction ): LocalizeState; In react-localize-redux index.d.ts will fix the issue but this may not be the optimal way.

What is the expected behavior? I expect i to run, as it would when i have used normal redux

Which versions of react and react-localize-redux are you using? "react": "17.0.1", "typescript": "~4.3.5", "react-redux": "^7.2.6", "@reduxjs/toolkit": "^1.6.2", "react-localize-redux": "^3.5.3",

MagnusHopland avatar Nov 01 '21 08:11 MagnusHopland