Typescript Error: Could not find a declaration file for module 'react-dnd'

Typescript Error: Could not find a declaration file for module '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 构建的。

react-dnd 确实附带了类型定义,如您在 unpkg 中所见。您无需执行任何操作即可访问这些类型。也许您使用的是 react-dnd 的旧版本,它没有包含这些类型?