in packages/babel-plugin-fbt/src/FbtUtil.js [737:764]
function getBinaryExpressionOperands(
moduleName: JSModuleNameType,
node: BabelNodeExpression,
): Array<
BabelNodeCallExpression | BabelNodeStringLiteral | BabelNodeTemplateLiteral,
> {
switch (node.type) {
case 'BinaryExpression':
if (node.operator !== '+') {
throw errorAt(node, 'Expected to see a string concatenation');
}
return [
...getBinaryExpressionOperands(moduleName, node.left),
...getBinaryExpressionOperands(moduleName, node.right),
];
case 'CallExpression':
case 'StringLiteral':
case 'TemplateLiteral':
return [node];
default:
throw errorAt(
node,
`Unexpected node type: ${node.type}. ` +
`The ${moduleName}() string concatenation pattern only supports ` +
` string literals or constructs like ${moduleName}.param().`,
);
}
}