From 286df9000efb324671ca61b69263cdb1c19f8c0b Mon Sep 17 00:00:00 2001 From: Sota Ogo Date: Tue, 14 Sep 2021 11:46:18 -0700 Subject: [PATCH] Throw when extendsProps is empty Summary: If I understand the code correctly, component.extendsProps is expected to have more than 1 entry. I encounter a bug where it was an empty and produced an broken Props.h file while testing out in OSS. ``` // Example of the broken file. class RNTMyNativeViewProps final : { public: ``` In this diff, it makes it clear that the function has failed so that the codegen fails when the input is wrong. There is probably an upstream problem that we should warn about, but this diff is just to make sure this method fails loudly. Changelog: [Internal] Reviewed By: hramos Differential Revision: D30847173 fbshipit-source-id: 34c894f0a7bb81e132b6ed44f51d0f92ed9a5a20 --- .../src/generators/components/GeneratePropsH.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index bdbd5886294..6cb6ca5bc2b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -187,6 +187,9 @@ static inline std::string toString(const ::_ENUM_MASK_:: &value) { `.trim(); function getClassExtendString(component): string { + if (component.extendsProps.length === 0) { + throw new Error('Invalid: component.extendsProps is empty'); + } const extendString = ' : ' + component.extendsProps