Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Codegen]: Extract contents of the case 'BooleanTypeAnnotation' into a single emitBoolean function #34907

Closed

Conversation

tarunrajput
Copy link
Contributor

Summary

Part of #34872

This PR extracts the content of the case 'BooleanTypeAnnotation' (Flow, TypeScript) into a single emitBoolean function in the parsers-primitives.js file. Use the new function in the parsers.

Changelog

[Internal] [Changed] - Extract contents of the case 'BooleanTypeAnnotation' into a single emitBoolean function

Test Plan

Run yarn jest react-native-codegen

image

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 9, 2022
@analysis-bot
Copy link

analysis-bot commented Oct 9, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 7227bde
Branch: main

@analysis-bot
Copy link

analysis-bot commented Oct 9, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,747,611 +0
android hermes armeabi-v7a 7,149,395 +0
android hermes x86 8,058,588 +0
android hermes x86_64 8,029,524 +0
android jsc arm64-v8a 9,608,518 +0
android jsc armeabi-v7a 8,373,768 +0
android jsc x86 9,555,784 +0
android jsc x86_64 10,148,324 +0

Base commit: 7227bde
Branch: main

@facebook-github-bot
Copy link
Contributor

@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this. 👏 That's amazing!

We can improve the quality even further by adding a unit test.
The steps should be:

  1. add the __tests__ subfolder in the packages/react-native-codegen/src/parsers.
  2. add a parser-primitives-test.js where we unit test this fuction:
    1. we test the output when the nullable parameter is false
    2. we test the output when the nullable parameter is true

An example of unit test can be found here.

Thank you so much! 🙏

@tarunrajput tarunrajput requested review from cipolleschi and removed request for rshest October 9, 2022 16:08
@facebook-github-bot
Copy link
Contributor

@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @tarunrajput in 7a2e346.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 9, 2022
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…itBoolean function (facebook#34907)

Summary:
Part of facebook#34872

This PR extracts the content of the case 'BooleanTypeAnnotation' ([Flow](https://github.com/facebook/react-native/blob/b444f0e44e0d8670139acea5f14c2de32c5e2ddc/packages/react-native-codegen/src/parsers/flow/modules/index.js#L365-L367), [TypeScript](https://github.com/facebook/react-native/blob/00b795642a6562fb52d6df12e367b84674994623/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L400-L402)) into a single emitBoolean function in the parsers-primitives.js file. Use the new function in the parsers.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - Extract contents of the case 'BooleanTypeAnnotation' into a single emitBoolean function

Pull Request resolved: facebook#34907

Test Plan:
Run ```yarn jest react-native-codegen```

<img width="803" alt="image" src="https://user-images.githubusercontent.com/34857453/194751101-3b1a619e-332a-43a9-bfa3-35f5869d7c5f.png">

Reviewed By: cipolleschi

Differential Revision: D40212518

Pulled By: cipolleschi

fbshipit-source-id: 9c1462c1e51a1836f963866dc4101f081898df00
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. hacktoberfest-accepted Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants