[英]Redux typescript-eslint/no-unsafe-assignment - useDispatch
I am using React, TypeScript, ESlint, and TypeScript-ESlint.我正在使用 React、TypeScript、ESlint 和 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.当我安装 Redux、React-Redux 和 @types/react-redux 时,TypeScript-ESlint 会忽略 Redux 类型。 I also installed and uninstalled @types/redux.
我还安装和卸载了@types/redux。
Everything in the Redux API like useDispatch(), useSelector(), combineReducers() throws linting errors for "Unsafe assignment of an any
value." Redux API 中的所有内容,如 useDispatch()、useSelector()、combineReducers() 都会为“不安全地分配
any
值”引发 linting 错误。
From the Redux Docs, useDispatch() should work without any special typing.从 Redux 文档中, useDispatch() 应该可以在没有任何特殊输入的情况下工作。
How can I configure TypeScript-ESlint to work with Redux?如何配置 TypeScript-ESlint 以使用 Redux?
Thanks!谢谢!
Sometimes, the typescript language server within vs code has a hard time picking up changes to the types.有时,vs 代码中的 typescript 语言服务器很难接受对类型的更改。 Try to "Reload" it using the command palette or completely restarting vs code.
尝试使用命令面板“重新加载”它或完全重新启动 vs 代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.