typescript 找不到模块“react-redux”的声明文件。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41647556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:10:12  来源:igfitidea点击:

Could not find a declaration file for module 'react-redux'.

reactjstypescriptredux

提问by Андрей Гузюк

Got an issue with typescript and react + redux

打字稿和反应 + redux 有问题

Could not find a declaration file for module 'react-redux'. '/home/andrew/miramir/src/js/node_modules/react-redux/lib/index.js' implicitly has an 'any' type.

Trying to get Provider from react-redux

尝试从 react-redux 获取 Provider

import { Provider } from 'react-redux';

How i can fix it? Thanks

我该如何解决?谢谢

回答by RoelVB

You should just add the needed types to your project, like this:

您应该将所需的类型添加到您的项目中,如下所示:

npm install --save-dev @types/react-redux

回答by Андрей Гузюк

Fixed with

固定与

const { Provider } = require('react-redux');