-
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: bring back simplified types for SerializeFrom #6746
Conversation
Hi @afoures, Welcome, and thank you for contributing to Remix! 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 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 |
|
…seFetcher, SerializeFrom
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Thank you for looking into this @afoures 🙏 Cool to see an example of a TS counter (via Summary of type expectation mismatches with this approach: 👆 like you already mentioned, inferred types for circularly referenced like 👆another example of the same thing, this time with 👆 Haven't checked if this is another example yet or its own issue, but type names for Currently, I'm not convinced that the added complexity here is worth it when it doesn't solve the issue for any circularly referenced types. While it does improve the DX slightly for cases where there are no circularly referenced types, it creates even more confusion once users do include such a type. And they may not even be aware that the type is circular! Circularly referenced types are not rare (e.g. |
You're right, I did not see that |
@afoures you are more than welcome to and I'm definitely curious what a solution would look like! That said, if the solution turns out to be significantly complex, we'll have to weigh the trade-offs carefully. |
@afoures closing this for now, but if you come up with a solution for circular types, I'm happy to reopen. |
One more thing is that we are trying to move to |
just saw that #6736 removed pretty types for SerializeFrom because of circular dependencies and infinitely recursive types.
this is an attempt to fix the infinitely recursive issue without loosing type simplification.
i tested it using the same Typescript playground.
there is one issue for circular types, where we loose the type name: in the playground, the name of
Stripe.InvoiceLineItem
is lost.this happen when
[T] extends [U]
intype PrettyTransform<T, U> = [T] extends [U] ? T : Pretty<U>;
is evaluated to false, and that is the case whenT
is a infinite circular type, at one pointU
will have the circular property evaluated tonever
because max depth is reached, soT
andU
are not the same anymore. i'm not sure how we could fix it.