fix(form-core): exclude undefined from FormState errors type#2066
Conversation
The runtime code filters out undefined values from the errorMap when building the errors array (via .filter(val => val !== undefined)), but the type definition allowed undefined in the union. This forced consumers to add unnecessary runtime undefined checks when iterating over errors. Wrapping the error union with NonNullable aligns the type with the actual runtime behavior. Fixes TanStack#2022
|
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR tightens TypeScript type definitions for form error arrays by wrapping error element unions with ChangesError Type Nullability
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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)
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 |
|
View your CI Pipeline Execution ↗ for commit 433005e
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2066 +/- ##
==========================================
+ Coverage 90.35% 90.71% +0.36%
==========================================
Files 38 59 +21
Lines 1752 2198 +446
Branches 444 550 +106
==========================================
+ Hits 1583 1994 +411
- Misses 149 183 +34
- Partials 20 21 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The runtime code in
FormApi.tsexplicitly filters outundefinedvalues from the error map when building theerrorsarray:But the type definition allows
undefinedin the union, forcing consumers to add unnecessaryundefinedchecks:This wraps the error union types with
NonNullable<>in both theFormState.errorstype and thegetAllErrors()return type, aligning the types with the runtime behavior.Fixes #2022
Summary by CodeRabbit