✨ fix(types): allow undefined value with async defaultValues in Contr…#13160
Merged
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom Nov 24, 2025
Conversation
bluebill1049
approved these changes
Nov 24, 2025
|
That actually broke types of the values for the case where |
1 task
1 task
Etsija
added a commit
to eclipse-apoapsis/ort-server
that referenced
this pull request
Dec 1, 2025
[1] adds `undefined` to `ControllerRenderProps['value']` type during async `defaultValues ` resolution, and this causes some TypeScript errors in our components. Fix by - Adding null coalescing operators for array field values - Adding early return guards for potentially undefined values - Refactoring reduce logic for cleaner type inference [1]: react-hook-form/react-hook-form#13160 Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
Etsija
added a commit
to eclipse-apoapsis/ort-server
that referenced
this pull request
Dec 1, 2025
[1] adds `undefined` to `ControllerRenderProps['value']` type during async `defaultValues ` resolution, and this will cause some TypeScript errors in some components. Fix by - Adding null coalescing operators for array field values - Adding early return guards for potentially undefined values - Refactoring reduce logic for cleaner type inference It has been verified that the fixes can be applied before the upgrade without breaking the build. [1]: react-hook-form/react-hook-form#13160 Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
sschuberth
pushed a commit
to eclipse-apoapsis/ort-server
that referenced
this pull request
Dec 1, 2025
[1] adds `undefined` to `ControllerRenderProps['value']` type during async `defaultValues ` resolution, and this will cause some TypeScript errors in some components. In preparation for the upgrade, add null coalescing operators for array field values and early return guards for potentially undefined values. [1]: react-hook-form/react-hook-form#13160 Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
github-merge-queue bot
pushed a commit
to eclipse-apoapsis/ort-server
that referenced
this pull request
Dec 1, 2025
[1] adds `undefined` to `ControllerRenderProps['value']` type during async `defaultValues ` resolution, and this will cause some TypeScript errors in some components. In preparation for the upgrade, add null coalescing operators for array field values and early return guards for potentially undefined values. [1]: react-hook-form/react-hook-form#13160 Signed-off-by: Jyrki Keisala <jyrki.keisala@doubleopen.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13125
Summary
When using
useFormwithdefaultValues: async () => {...}, the first renderprovides
field.valueasundefined, while the TypeScript types currently infera non-nullable value. This type mismatch can cause runtime errors if the user
assumes
field.valueis always defined.What this PR changes
ControllerRenderProps['value']to includeundefinedfor the initialasync defaultValues resolution.
Impact
This is a type-level fix that aligns TypeScript with real runtime behavior.
It may expose new TS errors where user code assumed
field.valuewas alwaysdefined, but it prevents runtime crashes and improves type safety.
Tests