( ts: TypeScript, factory: typescript.NodeFactory, node: typescript.JsxAttributes, msg: MessageDescriptor, ast?: boolean )
| 780 | } |
| 781 | |
| 782 | function generateNewProperties( |
| 783 | ts: TypeScript, |
| 784 | factory: typescript.NodeFactory, |
| 785 | node: typescript.JsxAttributes, |
| 786 | msg: MessageDescriptor, |
| 787 | ast?: boolean |
| 788 | ) { |
| 789 | const newProps = [ |
| 790 | factory.createJsxAttribute( |
| 791 | factory.createIdentifier('id'), |
| 792 | factory.createStringLiteral(msg.id) |
| 793 | ), |
| 794 | ...(msg.defaultMessage |
| 795 | ? [ |
| 796 | factory.createJsxAttribute( |
| 797 | factory.createIdentifier('defaultMessage'), |
| 798 | ast |
| 799 | ? factory.createJsxExpression( |
| 800 | undefined, |
| 801 | messageASTToTSNode(factory, parse(msg.defaultMessage)) |
| 802 | ) |
| 803 | : factory.createStringLiteral(msg.defaultMessage) |
| 804 | ), |
| 805 | ] |
| 806 | : []), |
| 807 | ] |
| 808 | for (const prop of node.properties) { |
| 809 | if ( |
| 810 | ts.isJsxAttribute(prop) && |
| 811 | ts.isIdentifier(prop.name) && |
| 812 | MESSAGE_DESC_KEYS.includes(prop.name.text as keyof MessageDescriptor) |
| 813 | ) { |
| 814 | continue |
| 815 | } |
| 816 | if (ts.isJsxAttribute(prop)) { |
| 817 | newProps.push(prop) |
| 818 | } |
| 819 | } |
| 820 | return newProps |
| 821 | } |
| 822 | |
| 823 | function extractMessagesFromCallExpression( |
| 824 | ts: TypeScript, |
no test coverage detected