找不到模块 'react-select/async' 的声明文件

Could not find a declaration file for module 'react-select/async'

我已经安装了 react-select 3.1.0 但是当我尝试按照文档中的定义导入此文件时,出现错误。

/home/ 中的 TypeScript 错误.../src/core/components/kiosk/Component_file.tsx(3,25): 找不到模块 'react-select/async' 的声明文件。 '/home/.../node_modules/react-select/async/dist/react-select.cjs.js' 隐式具有 'any' 类型。 TS7016

导入代码行:

import AsyncSelect from 'react-select/async';

谢谢你提前解决了我的问题

因为我在打字稿中工作。我刚刚更改了包路径。我在它前面加上@types.

@types/react-select/async

您可以在node_modules中看到@types目录。