mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
a669de1dd2
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46845 Previously, the parser was throwing away the values of a string union when storing it in the schema. It would only store the union as ``` { type: 'UnionTypeAnnotation', memberType: 'StringTypeAnnotation' } ``` We now track the string literals through the parser and store them in the schema: ``` { type: 'StringLiteralUnionTypeAnnotation', types: [ { type: 'StringLiteralTypeAnnotation' value: 'light' }, { type: 'StringLiteralTypeAnnotation' value: 'dark' }, ], } ``` We aren't changing the generators, those still just output "string". They could eventually be made smarter. The value of this is that the compat checker can now error when the union changes. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D63917685 fbshipit-source-id: 34a10e1f1910d2935837a3659f66049fd4473134
@react-native/codegen
Installation
yarn add --dev @react-native/codegen
Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like
Testing
To run the tests in this package, run the following commands from the React Native root folder:
yarnto install the dependencies. You just need to run this onceyarn jest packages/react-native-codegen.