fix(types): allow narrower HTMLElement types in function refs#14529
fix(types): allow narrower HTMLElement types in function refs#145297inspire wants to merge 1 commit intovuejs:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes TypeScript type checking for function refs by introducing a bivarianceHack pattern to the VNodeRef type, allowing refs to accept specific element types like HTMLFormElement instead of just the generic Element type. A test assertion verifies the fix works correctly. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Fixes #13969.
VNodeReffunction refs are currently typed with a callback parameter of:Element | ComponentPublicInstance | nullUnder TypeScript function parameter variance, this rejects callbacks that use a narrower DOM type, e.g.: