fix(sdk): accept key on intrinsic elements - #77
Conversation
Under jsx: "react-jsx" TypeScript checks a keyed intrinsic's props against IntrinsicElements[tag] directly, so JSX.IntrinsicAttributes alone did not admit key on <column>, <text>, <icon>, and friends. Every mapped list of children hit TS2322 and lost a check round to it; eight of twenty agents in the render-loop cadence experiment did. The reconciler already reads key for positional diffing (jsx() merges it into props), so this is a typing gap, not a runtime one. Add KeyedProps to BoxProps, TextProps, and IconProps; add a check regression test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Greptile SummaryWidget authors can now use stable Confidence Score: 5/5The change is safe to merge: intrinsic key typing and runtime key propagation both behaved as intended. All intrinsic element kinds were compiled with valid string and numeric keys, invalid boolean keys were rejected, and a before-and-after runtime harness verified keyed reordering without node removal. The focused CLI test and repository typecheck also completed successfully. Files Needing Attention: No files need follow-up attention.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(sdk): accept key on intrinsic elemen..." | Re-trigger Greptile |
What
<column key={day}>failedweaver checkwith TS2322 ("Property 'key' does not exist on type 'GradientBoxProps'"). Underjsx: "react-jsx"TypeScript checks a keyed intrinsic's props againstIntrinsicElements[tag]directly, so the existingJSX.IntrinsicAttributes.keynever applied to intrinsics.Adds a
KeyedPropsinterface toBoxProps,TextProps, andIconProps. The reconciler already forwardskey(thejsx()factory merges it into props) and uses it for positional diffing, so this is purely a typing gap.Receipts
cli/test/jsx-key.test.mjs: keyed<column>,<text>, and<icon>inside a.map()passweaver check. Fails on master, passes here.npm run typecheckandnpm test: 118 passed.Why it matters
Eight of twenty agents in the render-loop cadence experiment (
experiments/render-loop-cadence/SYNTHESIS.md, finding 5) wrotekeyon a mapped intrinsic, hit this, and spent a check round removing it.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.