Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type mismatch when using redux toolkit with Typescript #229

Open
MagnusHopland opened this issue Nov 1, 2021 · 0 comments
Open

Type mismatch when using redux toolkit with Typescript #229

MagnusHopland opened this issue Nov 1, 2021 · 0 comments

Comments

@MagnusHopland
Copy link

MagnusHopland commented Nov 1, 2021

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",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant