Type 'bigint' is not assignable to type 'Key | null | undefined' when trying to use virtualItem.key as react component key
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
index.d.ts の98行目にある生成された型宣言から始め、リンクされた StackBlitz の例の main.tsx でエラーを再現します。TypeScript 4.9.5 で公開されている virtualItem.key の型と React の key の型を比較します。key={virtualItem.key} が String の workaround を必要とせずに型チェックを通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
<SomeItem key={virtualItem.key} />
results in:
Type 'Key' is not assignable to type 'Key | null | undefined'.
Type 'bigint' is not assignable to type 'Key | null | undefined'.ts(2322)
index.d.ts(98, 9): The expected type comes from property 'key' which is declared here on type 'IntrinsicAttributes'
I suspect this may be due to being on an older version of React than what the Key type is targeting? But I don't think this should matter.
const key = String(virtualItem.key); works fine as a workaround, but it'd be nice if either:
Keytype from installed version of React is usedKeytype is inferred fromgetItemKeyKeytype could be passed to useVirtualizer, likeuseVirtualizer<TItemKey>(...)
As always, great job with this library. I love it! ❤
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-virtual-pksf2gfh?file=src%2Fmain.tsx
Steps to reproduce
- Open StackBlitz link
- In main.tsx, scroll down to
key={virtualRow.key}and see the type error
Expected behavior
Shouldn't get a type error
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- MacOS 14.4
- VSCode 1.98.2
- TypeScript 4.9.5
tanstack-virtual version
@tanstack/[email protected]
TypeScript version
4.9.5
Additional context
No response
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- 主要言語
- TypeScript
- スター
- 7.1k
- フォーク
- 472
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 12
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/virtual のほかの issue
-
measureElement caches 0 size for nodes that aren't attached yet (Vue: rows stack at start 0 and the list scrolls away on mount)対応中かも @webn00b が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
`scrollToIndex(last, { align: 'end' })` stays short of the end after a measured row grows (virtual-core ≥ 3.17.0)対応中かも @minwookshin が 7 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
TanStack/virtual#1290 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
virtual-core: desktop Safari drops the prepend anchor write when history lands during the top rubber-band bounce対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
marko-virtual: scrollToEnd during an in-flight prepend strands the view one prepend above the bottom (chat-pretext e2e fails on CI)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
TanStack/virtual の issue をすべて見る
似ている issue
-
bot:ai-assisted status:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
midnightntwrk/midnight-js#1424 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mksglu/context-mode#1268 ·
メンテナーはふだん 5 日以内に返信
-
[bug] Setup fails with "Cannot find matching keyid" when an older Node's corepack is on PATH対応中かも @EyalPoly が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MystenLabs/MemWal#1124 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Edit:オープンcheck:failed streams:edit
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
iptv-org/iptv#54352 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信