-
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
opt-in type inference for single-fetch #9272
Conversation
🦋 Changeset detectedLatest commit: f66de1a 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 |
57f8f07
to
7ad6d97
Compare
7ad6d97
to
5222956
Compare
Awesome! |
.changeset/young-eagles-grab.md
Outdated
|
||
Opt-in types for single-fetch | ||
|
||
To opt-in to type inference for single-fetch, add `future/single-fetch.d.ts` to `include` in your `tsconfig.json`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this API.
export function useLoaderData<T>(): T extends Loader | ||
? Awaited<ReturnType<T>> | ||
: never; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to fork in here and use the old SerializeFrom
types if a user returns a Response
from the loader
/action
since that will still go through res.json()
Note: using
include
rather thantypeRoots
/types
since those are designed for@types
packages andinclude
is lighter weight