gpt4 book ai didi

javascript - typescript 和@types/react 错误

转载 作者:行者123 更新时间:2023-12-04 15:52:10 26 4
gpt4 key购买 nike

我仍在学习将 TypeScript 与 React 结合使用。由于多慢react-scripts-ts是的,我被关闭了。我已经尝试使用 babel 7 ( react-webpack-typescript-babel ) 进行新的 typescript 设置,而且速度非常快。但是,有些基本错误我无法解决。

即使项目运行,在 vscode 中我得到以下错误:

  • [ts] 模块 ...@types/react... 没有导出成员“组件”
  • [ts] 类型“Counter”上不存在属性“setState”
  • [ts] 模块 ...@types/react... 没有导出成员“SFC”
  • [ts] 未知的编译器选项“esModuleInterop”
  • 还有更多...

我假设这是一个@types/react 和 typescript 问题。

  1. @types/react 没有更新吗?
  2. 如何让其他属性显示出来?
  3. 我也不知道什么时候可以从@types vs 使用除阅读以外的某些包中的@types包裹描述。

最佳答案

根据@lleon 的输入,旧的 typescript 版本是我头疼的原因。我删除了它 npm un -g typescript,添加了 vscode 用户设置 "typescript.tsdk": "node_modules\\typescript\\lib" 并重新启动了 vscode。目前运行良好。

关于javascript - typescript 和@types/react 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53418891/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com