react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Codegen] Replace ternary in assertGenericTypeAnnotationHasExactlyOneTypeParameter with typeParameterInstantiation attribute in parser

Open AntoineDoubovetzky opened this issue 2 years ago • 9 comments

Summary

Part of https://github.com/facebook/react-native/issues/34872:

Create a new function typeParameterInstantiation in the parsers.js file and add documentation to it. Implement it properly in the FlowParser.js and in the TypeScriptParser.js. Update the signature of assertGenericTypeAnnotationHasExactlyOneTypeParameter function to take the Parser instead of the language and use the new function in place of the ternary operator ?:.

There are 3 things I'm not sure about:

  1. The issue suggests to create a new function. For this case I believe an attribute is simpler. Is there a reason to prefer a function ?
  2. To update the tests I had to create a mocked parser. I created a new file parserMock (I took example on AnimatedMock). Does it seem ok ?
  3. I'm not sure what to add in the documentation of typeParameterInstantiation

Changelog

[Internal] [Changed] - Replace ternary in assertGenericTypeAnnotationHasExactlyOneTypeParameter with typeParameterInstantiation attribute in parser

Test Plan

I tested using Jest and Flow commands.

AntoineDoubovetzky avatar Nov 01 '22 07:11 AntoineDoubovetzky

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,066,177 +0
android hermes armeabi-v7a 6,438,561 +0
android hermes x86 7,481,495 +0
android hermes x86_64 7,340,889 +0
android jsc arm64-v8a 8,931,995 +0
android jsc armeabi-v7a 7,666,339 +0
android jsc x86 8,992,366 +0
android jsc x86_64 9,471,121 +0

Base commit: 19d65a2baff2b2ab10d423e33baf373712ceda93 Branch: main

analysis-bot avatar Nov 01 '22 08:11 analysis-bot

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

Base commit: 3d9a15da870a75ed76d60d0c9b0d38c351a15003 Branch: main

analysis-bot avatar Nov 01 '22 08:11 analysis-bot

PR build artifact for e65d4aabdbd5ab53de7b1028cea681ee026ccae2 is ready. To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

pull-bot avatar Nov 01 '22 08:11 pull-bot

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

facebook-github-bot avatar Nov 01 '22 09:11 facebook-github-bot

PR build artifact for f32eb3d81a0715d61bf23bd46dfd819c6fde0fca is ready. To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

pull-bot avatar Nov 02 '22 07:11 pull-bot

hi @AntoineDoubovetzky. Can I ask you to kindly rebase the PR? 🙏

cipolleschi avatar Nov 07 '22 17:11 cipolleschi

hi @AntoineDoubovetzky. Can I ask you to kindly rebase the PR? 🙏

Done 🙂

AntoineDoubovetzky avatar Nov 07 '22 17:11 AntoineDoubovetzky

PR build artifact for 6ca4f6806c58296cb50ec7a2806215880b118879 is ready. To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

pull-bot avatar Nov 07 '22 19:11 pull-bot

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

facebook-github-bot avatar Nov 08 '22 15:11 facebook-github-bot

This pull request was successfully merged by @AntoineDoubovetzky in 8a847a30e15e7d256a16a55b9ad875e666d76fbe.

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

react-native-bot avatar Nov 08 '22 20:11 react-native-bot