The example for `when` doesn't show that it takes the condition value as a parameter
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
Issue にリンクされている when ディレクティブのドキュメントから始め、その Signature ボックスと例を、ここで説明されている v3 API と比較します。次に、upstream の JSDoc の例を確認するために lit/packages/lit-html/src/directives/when.ts を調べます。両方の例で条件値が渡されていることが示され、ドキュメントのシグネチャが現在の API を正確に反映していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The when directive docs are out of date with the actual v3 API. Since lit#4310, when() passes the (type-narrowed) condition value to both case functions, but the docs don't reflect this.
1. The Signature box is wrong
It currently shows:
when<T, F>(
condition: boolean,
trueCase: () => T,
falseCase?: () => F
)
The actual v3 signature uses a generic condition and passes it to the callbacks:
when<C, T, F = undefined>(
condition: C,
trueCase: (c: Exclude<C, Falsy>) => T,
falseCase?: (c: Extract<C, Falsy>) => F
): C extends Falsy ? F : T
(We may want to simplify it for the docs? I'm not so sure)
2. The example doesn't use the parameter
It currently is:
${when(this.user, () => html`User: ${this.user.username}`, () => html`Sign In...`)}
It should show the value being passed in (and narrowed), which is the whole point of the feature:
${when(this.user, (user) => html`User: ${user.username}`, () => html`Sign In...`)}
Additional note
The same incomplete example is also in the upstream JSDoc at lit/packages/lit-html/src/directives/when.ts, so that may be worth updating too for consistency.
- 主要言語
- TypeScript
- スター
- 140
- フォーク
- 229
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lit/lit.dev のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
GetStream/stream-chat-react#3467 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
vercel-labs/ui#1139 ·
メンテナーはふだん 1 日以内に返信
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10対応中かも @goranai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bot:ai-assisted component:platform-js status:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
midnightntwrk/platform-js#93 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100