Setup for custom queries clashes with AllByAttribute type
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 48/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
从 issue 中链接的自定义查询设置页面开始,将其中的 JavaScript 示例与报告的 TypeScript 转换进行比较。更新该示例,使自定义查询符合文档规定的类型和 buildQueries 用法,然后验证 TypeScript 版本不再产生报告的类型错误。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
https://testing-library.com/docs/react-testing-library/setup#add-custom-queries
Existing setup for custom queries documentation does not work with typescript
To Reproduce
converting the following to typescript
const queryAllByDataCy = (...args) =>
queryHelpers.queryAllByAttribute('data-cy', ...args)
const queryAllByDataCy: AllByAttribute = (_, ...args) =>
queryHelpers.queryAllByAttribute('data-cy', ...args)
Produces a type error in the buildQueries function
type error
Argument of type 'AllByAttribute' is not assignable to parameter of type 'GetAllBy<[container: HTMLElement, id: Matcher, options?: MatcherOptions | undefined]>'.
Types of parameters 'attribute' and 'container' are incompatible.
Type 'HTMLElement' is not assignable to type 'string'.
buildQueries(queryAllByDataCy, getMultipleError, getMissingError)
Expected behavior
When converting the provided example to typescript the setup example should be in a format that conforms to the libraries type AllByAttribute.
This can be done by using partial application the container argument on queryHelpers.queryAllByAttribute and then updating the type of AllByAttribute to omit the partial argument
e.g.
js only:
const queryAllByDataCy = queryHelpers.queryAllByAttribute,bind(null, 'data-cy')
ts only:
type QueryAllByDataCy = (
container: HTMLElement,
id: Matcher,
options?: MatcherOptions
) => HTMLElement[]
const queryAllByDataCy: QueryAllByDataCy = queryHelpers.queryAllByAttribute,bind(null, 'data-cy')
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Ubuntu 20.04.2 LTS
- Typescript ^4.2.4
- Node 15.14.0
- 主要语言
- JavaScript
- 星标
- 479
- 派生
- 738
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testing-library/testing-library-docs 的其他 Issue
-
Broken Chrome Extension Link in Queries Docs可能已有人在做 @rajanpanth 于 60 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 72/100
testing-library/testing-library-docs#1499 ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
testing-library/testing-library-docs#1528 ·
维护者通常 4 天内回复
-
Framework wrappers and DOM testing library可能已有人在做 @jacklaurencegaray 于 422 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 38/100
testing-library/testing-library-docs#1493 · 3 条评论 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 55/100
testing-library/testing-library-docs#1486 · 1 个 reaction ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 48/100
testing-library/testing-library-docs#1485 · 1 条评论 ·
维护者通常 4 天内回复
查看 testing-library/testing-library-docs 的全部 Issue
相似的 Issue
-
[BUG]: Prompt compressor crashes with TypeError when a past chat has a non-string response.text可能已有人在做 @ManojDevarajulu 今天认领。 未关闭possible bug
难度 2/5 1-3 小时 新手友好度 82/100
Mintplex-Labs/anything-llm#6737 ·
维护者通常 1 天内回复
-
check:passed feeds:add
难度 2/5 1 小时以内 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 74/100
motiondivision/motion#3935 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
codex-team/editor.js#3037 ·
-
No Code Attached Yet
难度 2/5 1-3 小时 新手友好度 72/100
joomla/joomla-cms#48626 ·
维护者通常 1 天内回复