in packages/babel-plugin-fbt/src/babel-processors/JSXFbtProcessor.js [287:313]
_getDescAttributeValue() {
const {moduleName} = this;
const descAttr = getAttributeByNameOrThrow(
this._getOpeningElementAttributes(),
'desc',
);
const {node} = this;
if (!descAttr || descAttr.value == null) {
throw errorAt(node, `<${moduleName}> requires a "desc" attribute`);
}
switch (descAttr.value.type) {
case 'JSXExpressionContainer':
// @babel/parser should not allow this scenario normally
invariant(
descAttr.value.expression.type !== 'JSXEmptyExpression',
'unexpected',
);
return descAttr.value.expression;
case 'StringLiteral':
return descAttr.value;
}
throw errorAt(
node,
`<${moduleName}> "desc" attribute must be a string literal ` +
`or a non-empty JSX expression`,
);
}