( ts: TypeScript, factory: typescript.NodeFactory, node: typescript.ObjectLiteralExpression, msg: MessageDescriptor, ast?: boolean )
| 742 | } |
| 743 | |
| 744 | function setAttributesInObject( |
| 745 | ts: TypeScript, |
| 746 | factory: typescript.NodeFactory, |
| 747 | node: typescript.ObjectLiteralExpression, |
| 748 | msg: MessageDescriptor, |
| 749 | ast?: boolean |
| 750 | ) { |
| 751 | const newProps = [ |
| 752 | factory.createPropertyAssignment('id', factory.createStringLiteral(msg.id)), |
| 753 | ...(msg.defaultMessage |
| 754 | ? [ |
| 755 | factory.createPropertyAssignment( |
| 756 | 'defaultMessage', |
| 757 | ast |
| 758 | ? messageASTToTSNode(factory, parse(msg.defaultMessage)) |
| 759 | : factory.createStringLiteral(msg.defaultMessage) |
| 760 | ), |
| 761 | ] |
| 762 | : []), |
| 763 | ] |
| 764 | |
| 765 | for (const prop of node.properties) { |
| 766 | if ( |
| 767 | ts.isPropertyAssignment(prop) && |
| 768 | ts.isIdentifier(prop.name) && |
| 769 | MESSAGE_DESC_KEYS.includes(prop.name.text as keyof MessageDescriptor) |
| 770 | ) { |
| 771 | continue |
| 772 | } |
| 773 | if (ts.isPropertyAssignment(prop)) { |
| 774 | newProps.push(prop) |
| 775 | } |
| 776 | } |
| 777 | return factory.createObjectLiteralExpression( |
| 778 | factory.createNodeArray(newProps) |
| 779 | ) |
| 780 | } |
| 781 | |
| 782 | function generateNewProperties( |
| 783 | ts: TypeScript, |
no test coverage detected