Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error messages for invalid function types in react-native-cod…
…egen (#36498) Summary: The supported `CodegenTypes` aren't provided in the docs, which leads to many issues for developers working to transition native components to support Fabric. However, explicit error messages are provided in many cases (e.g., to use specific numeric types instead of `number` attributes or to remove nested optionals in arrays). This isn't the case for the common use case of TypeScript functions, which are very commonly used for event handlers in native components (such as `onChange`), forcing devs to search their way through the `react-native` codebase until they find [this file](https://github.com/facebook/react-native/blob/681d7f8113d2b5e9d6966255ee6c72b50a7d488a/Libraries/Types/CodegenTypes.js#L18). By providing an explicit error message, we can significantly improve developer experience for those working to transition libraries/components, leading to higher Fabric adoption. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [GENERAL] [ADDED] - Create explicit error message for TypeScript functions used as props in Codegen components, redirecting devs to the supported function types `BubblingEventHandler` and `DirectEventHandler`. Pull Request resolved: #36498 Test Plan: * `yarn run lint` shows no errors * no impact on `yarn && yarn jest react-native-codegen`, which failed 362 tests before and after my changes. Reviewed By: cipolleschi, sshic Differential Revision: D44132960 Pulled By: dmytrorykun fbshipit-source-id: d805ec8403613bf4e070cbd2904ff5a2648ec5fc
- Loading branch information