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

Function tryChangeModuleExportsObject

test/fixtures/snapshot/typescript.js:152299–152318  ·  view source on GitHub ↗

* Convert `module.exports = { ... }` to individual exports.. * We can't always do this if the module has interesting members -- then it will be a default export instead.

(object, useSitesToUnqualify)

Source from the content-addressed store, hash-verified

152297 * We can't always do this if the module has interesting members -- then it will be a default export instead.
152298 */
152299 function tryChangeModuleExportsObject(object, useSitesToUnqualify) {
152300 var statements = ts.mapAllOrFail(object.properties, function (prop) {
152301 switch (prop.kind) {
152302 case 172 /* SyntaxKind.GetAccessor */:
152303 case 173 /* SyntaxKind.SetAccessor */:
152304 // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`.
152305 // falls through
152306 case 297 /* SyntaxKind.ShorthandPropertyAssignment */:
152307 case 298 /* SyntaxKind.SpreadAssignment */:
152308 return undefined;
152309 case 296 /* SyntaxKind.PropertyAssignment */:
152310 return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify);
152311 case 169 /* SyntaxKind.MethodDeclaration */:
152312 return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify);
152313 default:
152314 ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind));
152315 }
152316 });
152317 return statements && [statements, false];
152318 }
152319 function convertNamedExport(sourceFile, assignment, changes, exports) {
152320 // If "originalKeywordKind" was set, this is e.g. `exports.
152321 var text = assignment.left.name.text;

Callers 1

convertAssignmentFunction · 0.85

Calls 3

concatMethod · 0.80

Tested by

no test coverage detected