Setup for custom queries clashes with AllByAttribute type
まだ誰も着手していません。
評価
- 難易度
- 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
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
testing-library/testing-library-docs のほかの issue
-
Vue - FAQ about Vue Router is outdated対応中かも @SatvikMishra08 が 9 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
testing-library/testing-library-docs#1570 · コメント 1 件 ·
-
Broken Chrome Extension Link in Queries Docs対応中かも @rajanpanth が 58 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
Framework wrappers and DOM testing library対応中かも @jacklaurencegaray が 420 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
testing-library/testing-library-docs#1493 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
testing-library/testing-library-docs#1486 · リアクション 1 件 ·
testing-library/testing-library-docs の issue をすべて見る
似ている issue
-
area: docs good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
Support
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
openseadragon/openseadragon#2996 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jfromaniello/url-join#134 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100