Search code examples
typescriptreduxeslinttypescript-eslint

Redux typescript-eslint/no-unsafe-assignment - useDispatch


enter image description here

I am using React, TypeScript, ESlint, and TypeScript-ESlint. There are no issues with this.

When I installed Redux, React-Redux, and @types/react-redux, the Redux types are being ignored by TypeScript-ESlint. I also installed and uninstalled @types/redux.

Everything in the Redux API like useDispatch(), useSelector(), combineReducers() throws linting errors for "Unsafe assignment of an any value."

From the Redux Docs, useDispatch() should work without any special typing. enter image description here

How can I configure TypeScript-ESlint to work with Redux?

Thanks!


Solution

  • Sometimes, the typescript language server within vs code has a hard time picking up changes to the types. Try to "Reload" it using the command palette (Ctrl+Shift+P or Cmd+Shift+P and searching for "restart") or completely restarting vs code.