Repository navigation
spec(AST-103): itemKey and the reported key are a string or a number - #8592
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 122594d |
PR Analysis Report
|
There was a problem hiding this comment.
One wording fix is needed before this lands: FR1 now calls itemKey "a string or a number, the same as React keys", but React's Key type in this repository (@types/react 19.2.17) is string | number | bigint, so the sentence both allows and excludes bigint keys, and the open List implementation in #8139 already types itemKey as React's Key. Please drop "React keys and" (Table's idKey and Core's own Key type are both string | number), or name React's Key if bigint keys are intended; the new head will need a fresh /approve-spec. The widening itself is owner-approved and contradicts no other current record.
[Automated review]
| Each item's key comes from the data, | ||
| never from React's `key`: List reads each `ListItem`'s `itemKey`, a string; | ||
| never from React's `key`: List reads each `ListItem`'s `itemKey`, a string or a number, the | ||
| same as React keys and Table's `idKey`, and `onReorder` reports that key as |
There was a problem hiding this comment.
React's Key in this repository's @types/react (19.2.17) is string | number | bigint, so "the same as React keys" and "a string or a number" disagree about bigint, and #8139 already types itemKey as React's Key. Dropping "React keys and" keeps the type that Table's idKey and Core's own Key already share; naming React's Key instead would admit bigint.
|
/approve-spec dfad545 |
There was a problem hiding this comment.
This spec change looks ready to land: FR1 now types itemKey, and the key onReorder reports, as a string or a number, matching what Table's idKey returns, and the earlier wording problem with React keys is gone. The rewrite is owner-approved for this head and contradicts no other current record. One follow-up outside this pull request: the List implementation in #8139 types itemKey as React's Key, which also allows bigint, so it will need to narrow to string | number to match.
[Automated review]
…3 FR1 now says meta#8592 changed FR1: List reads each ListItem's itemKey, a string or a number, the shape Table's idKey returns, and onReorder reports that key as given. The prop was a string only: it is now string | number (not React's Key, which also takes a bigint). The test moves a number-keyed row and a string-keyed row and checks each key comes back as given; a bigint key is a type error. ListItem's doc and createReorderable's advice say the same.
…string or a number spec:AST-103 FR1 (meta#8592): an item's key is a string or a number, and a reorderable object's keys default to that. The stories typed the key their owner's onReorder receives as React's Key, which also allows a bigint, so the object they made was a Reorderable<Key> that ListInput's reorderable prop does not take: the Storybook typecheck failed at four uses.
spec:AST-103 FR1 (meta#8592): an item's key is a string or a number, the shape ListItem's itemKey and Table's idKey take. createReorderable constrained its key type to React's Key, which also allows a bigint, so createReorderable<bigint> type-checked though no item could ever report such a key. The key type of the object, its options and its moves is now string | number. Failing-first: a @ts-expect-error on createReorderable<bigint> was unused (TS2578) before this; core's tsc passes now.
spec:AST-103 FR1 (meta#8592): an item's key is a string or a number, the shape ListItem's itemKey and Table's idKey take. createReorderable constrained its key type to React's Key, which also allows a bigint, so createReorderable<bigint> type-checked though no item could ever report such a key. The key type of the object, its options and its moves is now string | number. Failing-first: a @ts-expect-error on createReorderable<bigint> was unused (TS2578) before this; core's tsc passes now.
…string or a number spec:AST-103 FR1 (meta#8592): an item's key is a string or a number, and a reorderable object's keys default to that. The stories typed the key their owner's onReorder receives as React's Key, which also allows a bigint, so the object they made was a Reorderable<Key> that ListInput's reorderable prop does not take: the Storybook typecheck failed at four uses.
Summary
Record accuracy for
spec:AST-103. FR1 saysitemKeyis "a string", but FR1 also says a data collection without its own identity uses Table'sidKey, whose shape returnsstring | number, soonReorder's key can already be a number. This one-line change makesitemKey, and the keyonReorderreports, a string or a number, matching Table'sidKey.No behavior or other requirement changes.
Writing rubric results