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

feat: improve the Await props generics #10498

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

GiveMe-A-Name
Copy link

Now, when we use Await in ts project, the type will ignore because the define of Awaitcomponents.

For examples:
image

It no good for developer developed in IDE.

we can improve the Await Type System by generics.

e12d4589-fca9-44ad-a9e5-25fef2fd42bd

@changeset-bot
Copy link

changeset-bot bot commented May 17, 2023

⚠️ No Changeset found

Latest commit: 0c040ff

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented May 17, 2023

Hi @GiveMe-A-Name,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented May 17, 2023

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@fredericoo
Copy link

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

@GiveMe-A-Name
Copy link
Author

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

Thank you for your reply. Is there any other MR to improve it?

@fredericoo
Copy link

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

Thank you for your reply. Is there any other MR to improve it?

what's an MR? 😆

We need to make defer and json return the actual values rather than Response and DeferredValue, but that's quite the challenge. And also useLoaderData, useActionData, useRouteLoaderData could benefit from the same generics as in remix

@GiveMe-A-Name
Copy link
Author

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

Thank you for your reply. Is there any other MR to improve it?

what's an MR? 😆

We need to make defer and json return the actual values rather than Response and DeferredValue, but that's quite the challenge. And also useLoaderData, useActionData, useRouteLoaderData could benefit from the same generics as in remix

Sorry, My fault. That means PR.

In GitHub we called it PR(Pull Request) and in GitLab we called it MR(Merged Request). 😂

As your said, you will do some more work for this problem. Is means it will have an other PR to resolve it?

@fredericoo
Copy link

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

Thank you for your reply. Is there any other MR to improve it?

what's an MR? 😆
We need to make defer and json return the actual values rather than Response and DeferredValue, but that's quite the challenge. And also useLoaderData, useActionData, useRouteLoaderData could benefit from the same generics as in remix

Sorry, My fault. That means PR.

In GitHub we called it PR(Pull Request) and in GitLab we called it MR(Merged Request). 😂

As your said, you will do some more work for this problem. Is means it will have an other PR to resolve it?

Im working on it right now but it's much trickier than I first envisioned! It's all very intertwined: add a generic in one place and it errors out in 10 files. Feel free to implement it yourself too, as I’m finding it difficult to find the time to tackle all the type issues after work hours xd

@GiveMe-A-Name
Copy link
Author

Thank you so much! Lots of types can be synced between remix and react-router. I’ll do some more.

Thank you for your reply. Is there any other MR to improve it?

what's an MR? 😆
We need to make defer and json return the actual values rather than Response and DeferredValue, but that's quite the challenge. And also useLoaderData, useActionData, useRouteLoaderData could benefit from the same generics as in remix

Sorry, My fault. That means PR.
In GitHub we called it PR(Pull Request) and in GitLab we called it MR(Merged Request). 😂
As your said, you will do some more work for this problem. Is means it will have an other PR to resolve it?

Im working on it right now but it's much trickier than I first envisioned! It's all very intertwined: add a generic in one place and it errors out in 10 files. Feel free to implement it yourself too, as I’m finding it difficult to find the time to tackle all the type issues after work hours xd

Well, maybe I could also give it a try. This is not a serious problem for the developer.
It only affects the development experience, so we can work on it during our free time.

@brophdawg11
Copy link
Contributor

I just wanted to drop in here and say that in many cases we've specifically avoided adding the generics in React Router that we have in Remix (for things like useLoaderData, etc.) because they've never really been perfect, and are really just a lie to the compiler due to the indirection (and the fact that the types are serialized/deserialized in Remix). We weren't satisfied with them in Remix and didn't want to bring over a less-than-ideal set of generics to RR. Instead, we have ideas to improve on the types in Remix v2 and hopefully improve inference and reduce some of the needs for the generics.

So for now in RR, instead of useLoaderData<typeof loader>() just go with useLoaderData() as typeof loader.

Hopefully this'll all get much cleaner in the future.

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.

None yet

3 participants