-
Notifications
You must be signed in to change notification settings - Fork 25k
[Codegen 116] move getEventArgument function into parsers-commons.js
#37133
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
Conversation
|
Something to think about while moving
|
|
What I could do is pass a
|
d577313 to
0df6ad5
Compare
Base commit: 4fd8f40 |
|
@cipolleschi @rshest : All checks have passed, This PR is now ready for review. |
cipolleschi
left a comment
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.
Hi @siddarthkay, thank you so much for this PR.
I think that the work is very good, but these changes are a bit too disruptive, for the time being, considering also all the other people manipulating similar files.
Although I agree that in principle getPropertyType could be moved to the two parsers (and probably, eventually, it will be) I think that the task should be smaller, with fewer changes. We are taking an iterative approach, manipulating the files so that we will end up in the desired state with small steps.
What I had in mind, was to just move the function getEventArgument(argumentProps, name: $FlowFixMe) to the parsers.
Now, I see that:
- the function takes a
nameparameter which is not used => we can remove it - the function depends on
buildPropertiesForEvent=> we can pass it as a parameter.
So, the new signature (to be used in the parsers) would be
function getEventArgument(argumentProps: $FlowFixMe, buildPropertiesForEvent: (propert) => NamedShape<EventTypeAnnotation>)At this point, you don't have to refactor multiple functions and move all that code around.
In the callsite, you just replace the invocation with:
- getEventArgument(argumentProps, name),
+ getEventArgument(argumentProps, buildPropertiesForEvent), Does it make sense? how does it feel?
|
Hi @cipolleschi : Thanks for taking the time to go through the PR and suggesting an easier way to do this. I'll revert back my changes, rebase main and update the function signature of |
644f8ea to
d8924b0
Compare
cipolleschi
left a comment
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.
Thanks again! One last small change and we are good to import the PR! :D
f6cf9f8 to
f9119a8
Compare
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
@cipolleschi merged this pull request in d46f92c. |
…37133) Summary: [Codegen 116] This PR attempts to extract the logic of `getEventArgument` function from the following locations : - `parsers/flow/components/events.js` - `parsers/typescript/components/events.js` since they are the same and move the function to `parsers/parsers-commons.js` as requested on facebook#34872 ## Changelog: [Internal] [Changed] - Move `getEventArgument` to parser-commons and update usages. Pull Request resolved: facebook#37133 Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green Reviewed By: christophpurrer Differential Revision: D45569128 Pulled By: cipolleschi fbshipit-source-id: 63a7619e5b4fca0157c62a359ac51831f4f15945

Summary:
[Codegen 116] This PR attempts to extract the logic of
getEventArgumentfunction from the following locations :parsers/flow/components/events.jsparsers/typescript/components/events.jssince they are the same and move the function to
parsers/parsers-commons.jsas requested on ☂️ Improving Codegen #34872Changelog:
[Internal] [Changed] - Move
getEventArgumentto parser-commons and update usages.Test Plan:
Run
yarn jest react-native-codegenand ensure CI is green