Generate react-native turbo modules using TypeScript
OTHER License
TypeScript Code Generation for React Native Turbo Module
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
yarn
yarn build
yarn test
This is the shared tslint configuration for all other packages.
This is the TypeScript code generation for TurboModule in react native.
There are two important exported functions:
SchemaType
data structure.typeScriptToCodeSchema
['descriptors', 'events', 'props', 'tests', 'shadow-nodes', 'modules']
to control what files are generated.This package contains all test cases for RN-TSCodegen, with unit test code.
This is a Flow parser, just enough to convert necessary files to TypeScript for this repo.
Get generated files sync to facebook/react-native
You are welcome to use cli tool react-native-tscodegen
instead of calling functions in build scripts by yourself if possible.
Basically, just add react-native-tscodegen ./react-native-tscodegen.json
to npm scripts, after getting react-native-tscodegen.json
prepared.
The file name is not important.
{
"libraryName": "PlaygroundModule",
"outputDirectory": "./lib/cpp-generated",
"moduleSpecName": "PlaygroundModuleSpec",
"generators": [
"descriptors",
"events",
"props",
"tests",
"shadow-nodes",
"modules"
],
"inputFile": "./src/turboModule.ts"
}
libraryName
and moduleSpecName
control file names and some generated C++ class names.
generators
controls what files get generated.
After the cli tool is successfully executed,
files will be created under outputDirectory
.
git submodule update
pushd react-native
git fetch
git checkout <VERSION-NAME>
popd
git status
yarn
yarn build
pushd packages\update-test-files
npm run start
popd
git status
cls & pushd packages\update-test-files & npm run build & cd ..\RN-TSCodegen-Test & npm run build & popd
cls & pushd packages\RN-TSCodegen & npm run build & cd ..\RN-TSCodegen-Test & npm run build & npm run test & popd