-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(remix-react): add typeof action
inference to useFetcher
#4392
Conversation
🦋 Changeset detectedLatest commit: 21c74e5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
typeof action
inference to useFetcher
typeof action
inference to useFetcher
🤖 Hello there, We just published version Thanks! |
* Support `typeof action` in useFetcher generic type. * add myself to the list of contributors * Create witty-kiwis-flow.md Co-authored-by: Pedro Cattori <pcattori@gmail.com>
Closes Issue #: no official issue that I can find, but Kent mentioned in Discord that this would be a good contribution opportunity: https://discord.com/channels/770287896669978684/770287896669978687/1032333166402351154
This PR adds support for inferring the type of the
.data
property ofuseFetcher
from loader and action functions, similarly to how you can writeuseLoaderData<typeof loader>
. e.g. you can now writeuseFetcher<typeof action>
, andfetcher.data
will be inferred correctly. Previously, you had to writeuseFetcher<SerializeFrom<typeof action>>
.Docs:
How should this change best be documented? I struggled to find documentation for the matching changes to
useActionData
anduseLoaderData
outside of the changelog and thedecisions
documentation.Testing strategy:
If there are more official "type-level" tests for this sort of thing, to automate this testing, please point me in the right direction! I pattern-matched off of the similar inference that
useActionData
anduseLoaderData
support, and couldn't find any automated tests related to the types.contributing.md
.data
property of a fetcher (usinguseFetcher<typeof action>
) was typed as the action function type, with no inference of the return value.SerializeObject<UndefinedToOptional<{ /* action data */ }>> | undefined