( node: ExportAllDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration )
| 1083 | } |
| 1084 | |
| 1085 | private addExport( |
| 1086 | node: ExportAllDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration |
| 1087 | ): void { |
| 1088 | if (node instanceof ExportDefaultDeclaration) { |
| 1089 | // export default foo; |
| 1090 | |
| 1091 | this.assertUniqueExportName('default', node.start); |
| 1092 | this.exportDescriptions.set('default', { |
| 1093 | identifier: node.variable.getAssignedVariableName(), |
| 1094 | localName: 'default' |
| 1095 | }); |
| 1096 | } else if (node instanceof ExportAllDeclaration) { |
| 1097 | const source = node.source.value; |
| 1098 | this.addSource(source, node); |
| 1099 | if (node.exported) { |
| 1100 | // export * as name from './other' |
| 1101 | |
| 1102 | const name = node.exported instanceof Literal ? node.exported.value : node.exported.name; |
| 1103 | this.assertUniqueExportName(name, node.exported.start); |
| 1104 | this.reexportDescriptions.set(name, { |
| 1105 | localName: '*', |
| 1106 | module: null as never, // filled in later, |
| 1107 | source, |
| 1108 | start: node.start |
| 1109 | }); |
| 1110 | } else { |
| 1111 | // export * from './other' |
| 1112 | |
| 1113 | this.exportAllSources.add(source); |
| 1114 | } |
| 1115 | } else if (node.source instanceof Literal) { |
| 1116 | // export { name } from './other' |
| 1117 | |
| 1118 | const source = node.source.value; |
| 1119 | this.addSource(source, node); |
| 1120 | for (const { exported, local, start } of node.specifiers) { |
| 1121 | const name = exported instanceof Literal ? exported.value : exported.name; |
| 1122 | this.assertUniqueExportName(name, start); |
| 1123 | this.reexportDescriptions.set(name, { |
| 1124 | localName: local instanceof Literal ? local.value : local.name, |
| 1125 | module: null as never, // filled in later, |
| 1126 | source, |
| 1127 | start |
| 1128 | }); |
| 1129 | } |
| 1130 | } else if (node.declaration) { |
| 1131 | const declaration = node.declaration; |
| 1132 | if (declaration instanceof VariableDeclaration) { |
| 1133 | // export var { foo, bar } = ... |
| 1134 | // export var foo = 1, bar = 2; |
| 1135 | |
| 1136 | for (const declarator of declaration.declarations) { |
| 1137 | for (const localName of extractAssignedNames(declarator.id)) { |
| 1138 | this.assertUniqueExportName(localName, declarator.id.start); |
| 1139 | this.exportDescriptions.set(localName, { identifier: null, localName }); |
| 1140 | } |
| 1141 | } |
| 1142 | } else { |
no test coverage detected