Typescript React - 找不到模块“react-materialize”的声明文件。 'path/to/module-name.js' 隐式具有任何类型

2023-12-07

我正在尝试从 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和网络包。

The index.jsReact-Materialize 看起来像这样。但是如何解决我自己文件中的模块导入的问题呢?

https://github.com/react-materialize/react-materialize/blob/master/src/index.js


我有一个类似的错误,但对我来说是react-router。通过为其安装类型解决了这个问题。

npm install --save @types/react-router

Error:

(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 to false.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Typescript React - 找不到模块“react-materialize”的声明文件。 'path/to/module-name.js' 隐式具有任何类型 的相关文章

随机推荐