react-native
                                
                                 react-native copied to clipboard
                                
                                    react-native copied to clipboard
                            
                            
                            
                        [Codegen] Replace ternary in assertGenericTypeAnnotationHasExactlyOneTypeParameter with typeParameterInstantiation attribute in parser
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:
- 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 ?
- 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 ?
- 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.
| 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
| Platform | Engine | Arch | Size (bytes) | Diff | 
|---|---|---|---|---|
| ios | - | universal | n/a | -- | 
Base commit: 3d9a15da870a75ed76d60d0c9b0d38c351a15003 Branch: main
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.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
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.
hi @AntoineDoubovetzky. Can I ask you to kindly rebase the PR? 🙏
hi @AntoineDoubovetzky. Can I ask you to kindly rebase the PR? 🙏
Done 🙂
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.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was successfully merged by @AntoineDoubovetzky in 8a847a30e15e7d256a16a55b9ad875e666d76fbe.
When will my fix make it into a release? | Upcoming Releases