简体   繁体   English

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

[英]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.

相关问题 @typescript-eslint/no-unsafe-assignment:任何值的不安全赋值 - @typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value VSCode Eslint 错误 no-unsafe-assignment 显示不正确 - VSCode Eslint Error no-unsafe-assignment Incorrectly Displayed @typescript-eslint/no-unsafe-* 规则的新 eslint 错误 - New eslint errors with the @typescript-eslint/no-unsafe-* rules Vue 3 @typescript-eslint/no-unsafe-member-access - Vue 3 @typescript-eslint/no-unsafe-member-access Typescript:ESLint:任何类型值的不安全返回 @typescript-eslint/no-unsafe-return - Typescript : ESLint : Unsafe return of an any typed value @typescript-eslint/no-unsafe-return 即使输入了函数,我也会在导入的函数上出现 no-unsafe-call 和 no-unsafe-assignment eslint 错误 - I'm Getting no-unsafe-call and no-unsafe-assignment eslint error on imported function even though function is typed 任何值 ESLint 错误的 Typescript 不安全分配 - Typescript Unsafe Assignment of An Any Value ESLint Error 如何处理 catch(err) 块上的 @typescript-eslint/no-unsafe-member-access 规则? - How to handle the @typescript-eslint/no-unsafe-member-access rule on catch(err) blocks? typescript-eslint 未使用 tsconfig - tsconfig not used by typescript-eslint 如何将 typescript-eslint 规则添加到 eslint - How to add typescript-eslint rules to eslint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM