-
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
[rust] Refine typescript type generation #3239
[rust] Refine typescript type generation #3239
Conversation
…t relay-compiler-language-typescript package output.
readonly " $fragmentRefs": FragmentRefs<"PictureFragment">, | ||
} | null, | ||
readonly " $fragmentRefs": FragmentRefs<"OtherFragment" | "UserFrag1" | "UserFrag2">, | ||
readonly " $refType": FragmentRefs<"FragmentSpread">, |
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.
@kassens Just a FYI: If you were to switch the Flow emission to use types like these (based on strings) as well, instead of opaque types, we could get rid of any additional code related to haste or a specific artifact directory.
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.
Oh, interesting. This is using the fragment names and the fact that they're globally unique as their identifier, clever!
What about the property names? Why " $refType"
as the key (leading space?)
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.
So I wasn't involved with the original design behind the Typescript types, but I believe the leading space causes Typescript to omit this property in its autocomplete.
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.
So I wasn't involved with the original design behind the Typescript types, but I believe the leading space causes Typescript to omit this property in its autocomplete.
Correct 👍
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 just reviewed the emitted TS and it looks stellar to me 👌 Thanks! 🙏
Sorry for missing this! Curious about the import type, that's a new TypeScript feature, so it's there to support versions before and after TS 3.8? |
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.
@kassens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
No problem! Yeah, the |
Sorry for the delay, I was on vacation last week, but this should be merged in a bit! |
Thanks for the contribution again! Helps us slowly to get OSS ready! |
Fixes #3196
The generated output should now be basically identical to what is being generated over at relay-tools/relay-compiler-language-typescript. I didn't write a script to compare the fixtures in an automated manner, but compared samples by hand and fixed cases where the output from the Rust compiler differed.
Looking forward to your feedback!