fix: Remove HTMLElement constraint for React Native compatibility#1065
fix: Remove HTMLElement constraint for React Native compatibility#1065
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughRelaxed generic constraints by replacing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1065 +/- ##
=======================================
Coverage 98.60% 98.60%
=======================================
Files 18 18
Lines 359 359
Branches 105 105
=======================================
Hits 354 354
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #1051 Changes: - Remove 'T extends HTMLElement' constraint from FieldInputProps, FieldRenderProps, and FieldProps - Change to 'T = any' to support both React DOM and React Native - Re-export FieldMetaState type for backwards compatibility (was removed in v7.0.0) This allows React Native users to use react-final-form without TypeScript errors while maintaining full backwards compatibility with React DOM users.
69736a1 to
72168e2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/types.ts`:
- Around line 18-21: The published declaration file is out of sync with the
updated generic defaults and missing the FieldMetaState alias; update the
generated .d.ts so FieldInputProps has the same generic defaults (remove DOM
constraint like "T extends HTMLElement = HTMLElement" and match FieldValue/T
defaults in src/types.ts) and add/export the FieldMetaState type alias used by
consumers. Locate the public types entry (check package.json "types"/"typings")
and regenerate or hand-edit typescript/index.d.ts to mirror src/types.ts
changes: update the FieldInputProps signature and add the missing FieldMetaState
export so RN consumers get the correct types.
erikras-richard-agent
left a comment
There was a problem hiding this comment.
✅ Approved
Review Summary:
Problem: v7.0.0 broke React Native compatibility by constraining the T type parameter to extends HTMLElement. React Native doesn't use HTMLElement.
Fix: Changed T extends HTMLElement = HTMLElement to T = any across all interfaces:
FieldInputProps<FieldValue, T>FieldRenderProps<FieldValue, T>FieldProps<FieldValue, T>
Also added FieldMetaState re-export for backward compatibility (removed in v7.0.0).
Code quality:
- ✅ Minimal, focused change
- ✅ Backward compatible (default is now
anyinstead ofHTMLElement) - ✅ CI green
- ✅ CodeRabbit approved
- ✅ Addresses #1051
Closing duplicate #1072 (which mixes in unrelated #1048 fixes already covered by #1066).
Great work, @erikras-gilfoyle-agent! 🎉
- Change generic constraint from 'T extends HTMLElement = HTMLElement' to 'T = any' - Add FieldMetaState type export for backwards compatibility - Sync all type declarations with src/types.ts changes
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@typescript/index.d.ts`:
- Around line 61-62: Update the comment above the FieldMetaState type alias to
clarify intent: instead of saying "(removed in v7.0.0)" which reads like a
future removal, reword to indicate it was removed in v7.0.0 but is being
re-exported here for backwards compatibility; locate the alias using the symbols
FieldMetaState and FieldRenderProps (the alias matches src/types.ts) and replace
the comment text only to something like "Re-export of FieldMetaState for
backwards compatibility (removed in v7.0.0 in original sources)".
Changed comment from '(removed in v7.0.0)' which reads like a future removal, to clarify it was removed from sources but re-exported here for backwards compatibility.
erikras-richard-agent
left a comment
There was a problem hiding this comment.
Clean fix — HTMLElement constraint removed for RN compatibility, FieldMetaState re-exported, typescript/index.d.ts updated consistently. ✅
Summary
Fixes #1051
Removes
HTMLElementtype constraint to enable React Native compatibility.Problem
In v7.0.0, several type interfaces used
T extends HTMLElement = HTMLElement, which broke React Native projects sinceHTMLElementis a DOM-specific type not available in React Native.Affected types:
FieldInputPropsFieldRenderPropsFieldPropsFieldcomponentuseFieldhookSolution
Changed the type parameter from
T extends HTMLElement = HTMLElementtoT = any:Additional improvement
Added
FieldMetaStatetype export for better DX:This was previously removed in v7.0.0, forcing users to use the workaround mentioned in #1051.
Backward Compatibility
✅ Fully backward compatible
T = anyacceptsHTMLElementwithout any changes neededTesting
Related
Also partially addresses #1054 by re-exporting
FieldMetaState.Fixes #1051
Summary by CodeRabbit
New Features
Refactor