作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从react-materialize导入组件 -
import {Navbar, NavItem} from 'react-materialize';
但是当 webpack 编译我的 .tsx
时,它会抛出上述错误 -
ERROR in ./src/common/navbar.tsx
(3,31): error TS7016: Could not find a declaration file for module 'react-materi
alize'. 'D:\Private\Works\Typescript\QuickReact\node_modules\react-materialize\l
ib\index.js' implicitly has an 'any' type.
这个问题有解决办法吗?我不确定如何解析此导入语句以与 ts-loader
和 webpack 一起使用。
react-materialize 的 index.js
看起来像这样。但是我如何解决我自己文件中的模块导入的问题?
https://github.com/react-materialize/react-materialize/blob/master/src/index.js
最佳答案
我遇到了类似的错误,但对我来说是react-router
。通过为其安装类型解决了这个问题。
npm install --save @types/react-router
错误:
(6,30): error TS7016: Could not find a declaration file for module 'react-router'. '\node_modules\react-router\index.js' implicitly has an 'any' type.
如果您想在站点范围内禁用它,您可以编辑 tsconfig.json
并将 noImplicitAny
设置为 false
。
关于reactjs - Typescript React - 找不到模块 '' React-Materialize 的声明文件。 'path/to/module-name.js' 隐式具有任何类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41462729/
我是一名优秀的程序员,十分优秀!