【问题标题】:Could not find a declaration file for module 'react-select/async'找不到模块“react-select/async”的声明文件
【发布时间】:2021-01-18 23:49:02
【问题描述】:

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

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

导入代码行:

import AsyncSelect from 'react-select/async';

感谢您提前解决了我的问题

【问题讨论】:

  • 你安装了@types/react-select吗?
  • 一切都安装好了。
  • 你解决过这个问题吗?

标签: javascript reactjs react-select


【解决方案1】:

当我在打字稿工作时。我刚刚更改了包路径。我在它前面加上@types。

@types/react-select/async

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

【讨论】:

    猜你喜欢
    • 2019-03-16
    • 2019-07-26
    • 2021-02-21
    • 2017-05-29
    • 1970-01-01
    • 2022-06-12
    • 2022-11-06
    • 2021-09-03
    • 2021-08-25
    相关资源
    最近更新 更多