* Substitution for a BinaryExpression that may contain an imported or exported symbol. * * @param node The node to substitute.
(node)
| 105768 | * @param node The node to substitute. |
| 105769 | */ |
| 105770 | function substituteBinaryExpression(node) { |
| 105771 | // When we see an assignment expression whose left-hand side is an exported symbol, |
| 105772 | // we should ensure all exports of that symbol are updated with the correct value. |
| 105773 | // |
| 105774 | // - We do not substitute generated identifiers for any reason. |
| 105775 | // - We do not substitute identifiers tagged with the LocalName flag. |
| 105776 | // - We do not substitute identifiers that were originally the name of an enum or |
| 105777 | // namespace due to how they are transformed in TypeScript. |
| 105778 | // - We only substitute identifiers that are exported at the top level. |
| 105779 | if (ts.isAssignmentOperator(node.operatorToken.kind) |
| 105780 | && ts.isIdentifier(node.left) |
| 105781 | && !ts.isGeneratedIdentifier(node.left) |
| 105782 | && !ts.isLocalName(node.left) |
| 105783 | && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { |
| 105784 | var exportedNames = getExports(node.left); |
| 105785 | if (exportedNames) { |
| 105786 | // For each additional export of the declaration, apply an export assignment. |
| 105787 | var expression = node; |
| 105788 | for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { |
| 105789 | var exportName = exportedNames_3[_i]; |
| 105790 | // Mark the node to prevent triggering this rule again. |
| 105791 | noSubstitution[ts.getNodeId(expression)] = true; |
| 105792 | expression = createExportExpression(exportName, expression, /*location*/ node); |
| 105793 | } |
| 105794 | return expression; |
| 105795 | } |
| 105796 | } |
| 105797 | return node; |
| 105798 | } |
| 105799 | /** |
| 105800 | * Gets the additional exports of a name. |
| 105801 | * |
no test coverage detected