* 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)
| 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; |
no test coverage detected