MCPcopy Index your code
hub / github.com/nodejs/node / addExportEqualsIfNeeded

Function addExportEqualsIfNeeded

test/fixtures/snapshot/typescript.js:104667–104685  ·  view source on GitHub ↗

* Adds the down-level representation of `export=` to the statement list if one exists * in the source file. * * @param statements The Statement list to modify. * @param emitAsReturn A value indicating whether to emit the `export=` statement as a * return

(statements, emitAsReturn)

Source from the content-addressed store, hash-verified

104665 * return statement.
104666 */
104667 function addExportEqualsIfNeeded(statements, emitAsReturn) {
104668 if (currentModuleInfo.exportEquals) {
104669 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, visitor);
104670 if (expressionResult) {
104671 if (emitAsReturn) {
104672 var statement = factory.createReturnStatement(expressionResult);
104673 ts.setTextRange(statement, currentModuleInfo.exportEquals);
104674 ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */);
104675 statements.push(statement);
104676 }
104677 else {
104678 var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult));
104679 ts.setTextRange(statement, currentModuleInfo.exportEquals);
104680 ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */);
104681 statements.push(statement);
104682 }
104683 }
104684 }
104685 }
104686 //
104687 // Top-Level Source Element Visitors
104688 //

Callers 2

transformCommonJSModuleFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected