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

Function convertAssignment

test/fixtures/snapshot/typescript.js:152266–152294  ·  view source on GitHub ↗
(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify)

Source from the content-addressed store, hash-verified

152264 }
152265 }
152266 function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) {
152267 var left = assignment.left, right = assignment.right;
152268 if (!ts.isPropertyAccessExpression(left)) {
152269 return false;
152270 }
152271 if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left)) {
152272 if (ts.isExportsOrModuleExportsOrAlias(sourceFile, right)) {
152273 // `const alias = module.exports;` or `module.exports = alias;` can be removed.
152274 changes.delete(sourceFile, assignment.parent);
152275 }
152276 else {
152277 var replacement = ts.isObjectLiteralExpression(right) ? tryChangeModuleExportsObject(right, useSitesToUnqualify)
152278 : ts.isRequireCall(right, /*checkArgumentIsStringLiteralLike*/ true) ? convertReExportAll(right.arguments[0], checker)
152279 : undefined;
152280 if (replacement) {
152281 changes.replaceNodeWithNodes(sourceFile, assignment.parent, replacement[0]);
152282 return replacement[1];
152283 }
152284 else {
152285 changes.replaceRangeWithText(sourceFile, ts.createRange(left.getStart(sourceFile), right.pos), "export default");
152286 return true;
152287 }
152288 }
152289 }
152290 else if (ts.isExportsOrModuleExportsOrAlias(sourceFile, left.expression)) {
152291 convertNamedExport(sourceFile, assignment, changes, exports);
152292 }
152293 return false;
152294 }
152295 /**
152296 * Convert `module.exports = { ... }` to individual exports..
152297 * We can't always do this if the module has interesting members -- then it will be a default export instead.

Callers 1

convertStatementFunction · 0.85

Calls 4

convertReExportAllFunction · 0.85
convertNamedExportFunction · 0.85
deleteMethod · 0.65

Tested by

no test coverage detected