首页 > 解决方案 > 打字稿错误:找不到模块“react-dnd”的声明文件

问题描述

我目前在导入时收到此错误react-dnd

Could not find a declaration file for module 'react-dnd'. 'node_modules/react-dnd/lib/index.js' implicitly has an 'any' type.
Try `npm install @types/react-dnd` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-dnd';

react-dnd提供类型定义?我需要做些什么才能访问这些类型吗?

我在严格模式下使用打字稿。我的应用是用 create-react-app 搭建的。

标签: reactjstypescriptcreate-react-appreact-dnd

解决方案


react-dnd确实带有类型定义,正如您在unpkg中看到的那样。您不需要做任何事情来访问这些类型。也许您使用的是旧版本的 react-dnd,它没有包含类型?


推荐阅读