typescript - 预期的变量声明有一个 typedef
问题描述
我有这段代码显示警告:
const linkElement = getByText(/learn react/i);
预期的变量声明:'linkElement' 有一个 typedef (typedef)tslint(1)
getByText
键入:(text: Matcher, options?: SelectorMatcherOptions | undefined, waitForElementOptions?: unknown) => HTMLElement
为什么我明确需要声明一个 typedef 给定 TS 知道linkElement
是一个HTMLElement
?
我已将以下内容添加到我的.eslintrc
但警告仍然存在:
"plugins": [
"jsx-a11y",
"prefer-arrow",
"@typescript-eslint/tslint"
],
...
"rules": {
"@typescript-eslint/typedef": [
"off",
{
"variableDeclaration": false
}
],
"@typescript-eslint/no-inferrable-types": "error",
解决方案
推荐阅读
- sql - 基本 SQL 查询协助
- python - 如何使用间隔索引向熊猫数据框添加一行
- javascript - 从 Form 创建一个对象数组
- c++ - 声明期间的 C++ 赋值运算符
- sql - SSMS 能够与 localhost\foo 连接,但不能仅与 localhost 连接
- javascript - 如何根据月份和日期对该数组进行排序?
- delphi - 德尔福 10.4 和印地 9
- python - 无法解析 QGIS 中的函数
- apache-kafka - 在 Kafka 中,如何找到给定开始日期和结束日期(或说时间戳)之间所有分区的偏移量并重播 msgs
- reactjs - 如何在 google-map-react 中传递道具数据