mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
d2f3f06826
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46827 You can now define a native module that takes an argument that is a specific string literal: Like this: ``` export interface Spec extends TurboModule { +passString: (arg: string) => void; +passStringLiteral: (arg: 'A String Literal') => void; } ``` On the native side, this will still generate `string`, but the schema will now store the string literal, and it will be allowed in JS. This should allow more strict flow / typescript types for modules. This will also allow the compatibility check to fail if the literal changes. This is a step towards accepting a union of string literals. Changelog: [General][Added] Codegen for Native Modules now supports string literals Reviewed By: GijsWeterings Differential Revision: D63872440 fbshipit-source-id: e54b97d34af4a3d1af51727db0777f26fb7b778c
@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.