fix(react): allow key attribute on components created by with - #1981
fix(react): allow key attribute on components created by with#1981geongyu09 wants to merge 2 commits into
Conversation
People can be co-author:
|
|
@geongyu09 is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 5d341a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1981 +/- ##
=======================================
Coverage 93.22% 93.22%
=======================================
Files 42 42
Lines 664 664
Branches 163 164 +1
=======================================
Hits 619 619
Misses 42 42
Partials 3 3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused type fix is covered by regression tests, with no unresolved issues.
Pull request overview
Updates React with helpers so prop-less components accept the reserved key attribute while rejecting arbitrary props.
Changes:
- Updates default prop types across five helpers.
- Adds compile-time regression tests.
- Adds a patch changeset for
@suspensive/react.
File summaries
| File | Description |
|---|---|
packages/react/src/Suspense.tsx |
Updates default wrapped-component props. |
packages/react/src/Suspense.test-d.tsx |
Tests Suspense.with typing. |
packages/react/src/ErrorBoundaryGroup.tsx |
Updates default wrapped-component props. |
packages/react/src/ErrorBoundaryGroup.test-d.tsx |
Tests ErrorBoundaryGroup.with typing. |
packages/react/src/ErrorBoundary.tsx |
Updates default wrapped-component props. |
packages/react/src/ErrorBoundary.test-d.tsx |
Tests ErrorBoundary.with typing. |
packages/react/src/Delay.tsx |
Updates default wrapped-component props. |
packages/react/src/Delay.test-d.tsx |
Tests Delay.with typing. |
packages/react/src/ClientOnly.tsx |
Updates default wrapped-component props. |
packages/react/src/ClientOnly.test-d.tsx |
Tests ClientOnly.with typing. |
.changeset/fix-with-key-attribute.md |
Records the patch release. |
Review details
- Files reviewed: 11/11 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Overview
Suspense.with,ErrorBoundary.with,ErrorBoundaryGroup.with,Delay.with, andClientOnly.withreject the React-reservedkeyattribute when the wrapped component takes no props.Cause
The
TPropstype parameter of everywithhelper defaults toRecord<string, never>. Its string index signature makes every attribute — includingkey— resolve tonever, so TypeScript rejectskeyeven though React always accepts it on any element.Fix
Change the default to
Record<never, never>.It still means "no props" — arbitrary props such as
foo="bar"remain a type error — but it has no index signature, so React's ownkeyhandling applies again. The same change is applied to all five components for consistency.Tests
Added type tests (
*.test-d.tsx) for each of the fivewithhelpers covering:keyis accepted when the wrapped component has no props@ts-expect-error)keyworks alongside inferred propsAlso added a
patchchangeset for@suspensive/react.PR Checklist