Support mixed props for components

Summary:
Changelog:
[Changed][General] - Support mixed props for components in codegen

Reviewed By: rickhanlonii

Differential Revision: D43894460

fbshipit-source-id: e5faf2f83e6829170cdce550e923c3c09ddff0b0
This commit is contained in:
Genki Kondo
2023-03-19 16:47:22 -07:00
committed by Facebook GitHub Bot
parent e5b97f0f13
commit 0ae5e50e37
47 changed files with 949 additions and 4 deletions
@@ -20,6 +20,7 @@ import type {
FloatTypeAnnotation,
Int32TypeAnnotation,
PropTypeAnnotation,
MixedTypeAnnotation,
} from '../../../CodegenSchema';
const {capitalize} = require('../../Utils');
@@ -89,7 +90,8 @@ export type PojoTypeAnnotation =
type: 'ArrayTypeAnnotation',
elementType: PojoTypeAliasAnnotation,
}>,
}>;
}>
| MixedTypeAnnotation;
class PojoCollector {
_pojos: Map<string, Pojo> = new Map();
@@ -24,6 +24,7 @@ function toJavaType(
addImport('com.facebook.react.bridge.ReadableMap');
const importArrayList = () => addImport('java.util.ArrayList');
const importYogaValue = () => addImport('com.facebook.yoga.YogaValue');
const importDynamic = () => addImport('com.facebook.react.bridge.Dynamic');
switch (typeAnnotation.type) {
/**
* Primitives
@@ -222,6 +223,11 @@ function toJavaType(
return `ArrayList<${elementTypeString}>`;
}
case 'MixedTypeAnnotation': {
importDynamic();
return 'Dynamic';
}
default: {
(typeAnnotation.type: empty);
throw new Error(