* Check if node is `foo.bar.formatMessage` node * @param node * @param sf
( ts: TypeScript, node: typescript.CallExpression, additionalFunctionNames: string[] )
| 646 | * @param sf |
| 647 | */ |
| 648 | function isMemberMethodFormatMessageCall( |
| 649 | ts: TypeScript, |
| 650 | node: typescript.CallExpression, |
| 651 | additionalFunctionNames: string[] |
| 652 | ) { |
| 653 | const fnNames = new Set([ |
| 654 | 'formatMessage', |
| 655 | '$formatMessage', |
| 656 | ...additionalFunctionNames, |
| 657 | ]) |
| 658 | const method = node.expression |
| 659 | |
| 660 | // Handle foo.formatMessage() |
| 661 | if (ts.isPropertyAccessExpression(method)) { |
| 662 | return fnNames.has(method.name.text) |
| 663 | } |
| 664 | |
| 665 | // GH #4471: Handle foo.formatMessage<T>?.() - when both generics and optional chaining are used |
| 666 | // TypeScript represents this as ExpressionWithTypeArguments containing a PropertyAccessExpression |
| 667 | if ( |
| 668 | ts.isExpressionWithTypeArguments && |
| 669 | ts.isExpressionWithTypeArguments(method) |
| 670 | ) { |
| 671 | const expr = method.expression |
| 672 | if (ts.isPropertyAccessExpression(expr)) { |
| 673 | return fnNames.has(expr.name.text) |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | // Handle formatMessage() |
| 678 | return ts.isIdentifier(method) && fnNames.has(method.text) |
| 679 | } |
| 680 | |
| 681 | function extractMessageFromJsxComponent( |
| 682 | ts: TypeScript, |
no outgoing calls
no test coverage detected