2

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!

4
  • Sounds like you forgot to import it. Jan 6, 2022 at 0:24
  • 1
    Or you can try reloading your IDE (looks like VSCode, either by restarting it or "Reload" in the command palette), sometimes the ts language server is a bit slow in picking up changes.
    – Janik
    Jan 6, 2022 at 1:03
  • @Janik you are absolutely right, I didn't have any problems with earlier libraries before installing Redux so I didn't think it would be the editor. I did a hard quit and when I reopened the editor all of the typescript-eslint errors disappeared and I verified by building. Post as an answer and I'll select it. Jan 6, 2022 at 1:18
  • Great to hear it helped!
    – Janik
    Jan 6, 2022 at 1:24

1 Answer 1

5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.