in packages/codegen-ui-react/lib/react-studio-template-renderer.ts [404:442]
private buildComponentPropNode(component: StudioComponent): TypeNode | undefined {
const propSignatures: PropertySignature[] = [];
const bindingProps = component.bindingProperties;
if (bindingProps === undefined || !isStudioComponentWithBinding(component)) {
return undefined;
}
Object.entries(component.bindingProperties).forEach(([propName, binding]) => {
if (isSimplePropertyBinding(binding)) {
const propSignature = factory.createPropertySignature(
undefined,
propName,
factory.createToken(SyntaxKind.QuestionToken),
factory.createTypeReferenceNode(binding.type, undefined),
);
propSignatures.push(propSignature);
} else if (isDataPropertyBinding(binding)) {
const propSignature = factory.createPropertySignature(
undefined,
propName,
factory.createToken(SyntaxKind.QuestionToken),
factory.createTypeReferenceNode(binding.bindingProperties.model, undefined),
);
propSignatures.push(propSignature);
}
});
if (component.componentType === 'Collection') {
const propSignature = factory.createPropertySignature(
undefined,
'items',
factory.createToken(SyntaxKind.QuestionToken),
factory.createTypeReferenceNode('any[]', undefined),
);
propSignatures.push(propSignature);
}
if (propSignatures.length === 0) {
return undefined;
}
return factory.createTypeLiteralNode(propSignatures);
}