Skip to content
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

Merged
merged 8 commits into from
Apr 22, 2024

Conversation

pcattori
Copy link
Contributor

@pcattori pcattori commented Apr 21, 2024

Note: using include rather than typeRoots/types since those are designed for @types packages and include is lighter weight

Copy link

changeset-bot bot commented Apr 21, 2024

🦋 Changeset detected

Latest commit: f66de1a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@remix-run/react Patch
@remix-run/testing Patch
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch

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

@pcattori pcattori force-pushed the pedro/release-single-fetch-types branch from 57f8f07 to 7ad6d97 Compare April 21, 2024 16:35
@pcattori pcattori force-pushed the pedro/release-single-fetch-types branch from 7ad6d97 to 5222956 Compare April 21, 2024 16:41
@kiliman
Copy link
Collaborator

kiliman commented Apr 21, 2024

Awesome!


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`:
Copy link
Member

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.

Comment on lines 44 to 47
export function useLoaderData<T>(): T extends Loader
? Awaited<ReturnType<T>>
: never;

Copy link
Contributor

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/actionsince that will still go through res.json()

@brophdawg11 brophdawg11 self-assigned this Apr 22, 2024
@brophdawg11 brophdawg11 merged commit 2c207b6 into release-next Apr 22, 2024
5 checks passed
@brophdawg11 brophdawg11 deleted the pedro/release-single-fetch-types branch April 22, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants