【问题标题】:Typescript working in VScode, but eslint emitting react/prop-types error for inferred typesTypescript 在 VScode 中工作,但 eslint 为推断类型发出 react/prop-types 错误
【发布时间】:2021-06-12 11:54:44
【问题描述】:

在 VScode 中它可以正常工作,因为可以从 LeadInfo. 推断出类型

但是,Eslint 发出 missing props validation 的错误

顺便说一下,Column 来自React-table,我们已经按照react-table 建议的设置来自https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-table

【问题讨论】:

  • 放一个道具验证?
  • 嗨@CaiusJard,感谢您的建议,这确实可以解决问题。但我认为 eslint 在这种情况下不应该发出错误,因为可以从类型定义 Array<Column<LeadInfo>> 推断出类型。
  • 即使它不再是打字稿?
  • 嗨@CaiusJard,我不明白你所说的Even when it's no longer typescript是什么意思。

标签: reactjs typescript visual-studio-code eslint react-table


【解决方案1】:

在你的 eslint 配置中关闭 react/prop-types 规则,如果你使用 TS 没有多大意义

【讨论】:

  • 谢谢,你是对的!!我认为react/prop-types 是针对 JS 项目而不是 TS 项目的。
猜你喜欢
  • 2020-10-30
  • 2018-09-15
  • 1970-01-01
  • 2020-12-19
  • 2021-07-27
  • 1970-01-01
  • 2019-11-22
  • 1970-01-01
  • 2019-10-06
相关资源
最近更新 更多