mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
00b795642a
Summary: `TSParenthesizedType`, `TSUnionType`, `TSNullKeyword`, `TSUndefinedKeyword`, `TSVoidKeyword` etc are repeatly processed in so many places. In this change I put them in a new file `parseTopLevelType.js`, and everyone call that file, all repeat implementation are deleted. The `parseTopLevelType` function will look into a type consisted by the above types in any possible combination (but still very easy to do), and tell you if a type is nullable, or if there is a default value, and what is the real type with all noises removed. Array types and union types are processed in component twice, for property of array, and property of nested arrays (`componentsUtils.js`). They are extracted into single functions. ## Changelog [General] [Changed] - Refactor in turbo module TypeScript codegen: process `(T)`, `T|U`, `T|undefined` and related stuff in a central place Pull Request resolved: https://github.com/facebook/react-native/pull/34814 Test Plan: `yarn jest react-native-codegen` passed Reviewed By: yungsters, sammy-SC Differential Revision: D40094373 fbshipit-source-id: f28e145bc4e7734be9036815ea425d820eadb8f0
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 react-native-codegen.