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
This commit is contained in:
Sota Ogo
2021-09-14 11:46:18 -07:00
committed by Facebook GitHub Bot
parent 99bad7015a
commit 286df9000e
@@ -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