-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Better support for abstract types (unions and interfaces). #3178
base: main
Are you sure you want to change the base?
Better support for abstract types (unions and interfaces). #3178
Conversation
Represent the possible types and type names as unions in the Flow output, for more accurate typing.
Hi @MaartenStaa! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
1 similar comment
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Thanks for the PR! We agree that there are some changes and improvements that could be made to the Flow types for abstract types, so this is an area we're interested in revisiting at some point. However, some of the details of this PR are different than we had been planning, and there is a practical aspect to when we make this change and how to roll it out:
To summarize: we sincerely appreciate the contribution but we can't immediately proceed with this change as-is. If you're interested in contributing in this area, the more pressing concern is implementing Typescript type generation in the new Rust compiler - ie porting relay-tools/relay-compiler-language-typescript to Rust. Any interest? |
Thanks for your reply, let me reply point by point.
Makes sense to me. I know there's a flag
Great, that's exactly what I was going for!
I saw the Rust rewrite project, but found it difficult to judge in what phase that project is. Are you saying the aim is to release the new compiler later this year, replacing the current Javascript-based one at the same time.
Would it make sense to roll this out with a new major version number, to indicate that there may be breaking changes? I imagine so far the Rust rewrite is mirroring the original behaviour to be able to verify more easily whether the output is correct or not. Once it reaches feature parity however there'd be room to diverge if it will be released as a major update, meaning people would be consciously opting in to the new version.
That sounds like a fun challenge, let me see what I can cook up before heading on vacation this weekend. |
At facebook, we need the future proof stuff as React Native clients might be months out of date and should still be able to query. I think the no-future-proof version might be actually more common outside of facebook where you might either have a web-app and you can ignore short term "website push" inconsistencies or force React Native clients to update occasionally. I'd be pretty happy with having this an option, maybe even default to true option. I suspect the case where we keep The status of the Rust project is that we've just switched to using it internally for most parts, but OSS still has some outstanding work to switch. I just documented the things I could think of in #3180. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I would love to have the option to not future-proof unions. For more tightly coupled client and servers, statically enforcing exhaustive union checks is very helpful. We lose the ability to do that with the widening on That said, I'm still somewhat confused by the typing on unions and I wonder if there can be improvements made while still maintaining future-proofing. For example, with schema:
and mutation
we get:
why doesn't
That way we can get future-proofing but also enforce exhaustive checking on the current schema. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We still need this - currently interfaces and unions just result in things like |
Represent the possible types and type names as unions in the Flow output, for more accurate typing.
This is a direct port of my work at relay-tools/relay-compiler-language-typescript#192, I'm hoping we can include this upstream to keep the two repositories in line with each other and to bring these improvements to more people.
I'm looking forward to your feedback!
There are two Flow errors left due to it not understanding the value of a variable being narrowed down to an
AbstractTypeID
. I'm not very familiar with Flow, maybe you can help me with how to fix this.