Fix TTransformedValues inference for #12638#12664
Closed
controversial wants to merge 2 commits into
Closed
Conversation
This was referenced Mar 7, 2025
Member
|
aweomse thanks! could you update the API extractor? |
bluebill1049
approved these changes
Mar 8, 2025
Author
|
Now updated; sorry for the delay! @bluebill1049 |
Member
|
@controversial Thanks for your assistance. Could you please take a look at PR #12638 when you get a chance? |
Author
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.
cc @jorisre
fixes types as part of #12638
Why
(typeof props)['resolver']does not work because within the implementation signature, the value intypeof propsdoes not capture any specific type information that is not a part of theuseFormfunction’s generic type parameters.useFormis only generic over TFieldValues/TContext/TTransformedValues, there is no type information to be gained from(typeof props)['resolver']because the compiler will never see the type(typeof props)['resolver']as anything more specific thanResolver<TFieldValues, TContext, TTransformedValues>.resolvermatches TTransformedValuesprops.resolver, without using the broken ExtractTransformedValues type helperEffect
This PR fixes the broken types in the
handleSubmittests in react-hook-form/resolvers#753Before,

formis erroneously inferred with a TTransformedValues parameter ofany, and the test failsAfter,

forminfers the correct type for TTransformedValues and there is no type error; the test passes