Skip to content

Commit 9ce64c5

Browse files
committed
fix: Correctly handle export * from...
Closes #1186
1 parent f2d9c18 commit 9ce64c5

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/lib/converter/factories/reference.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export function createReferenceReflection(context: Context, source: ts.Symbol, t
4545
context.scope.children = [];
4646
}
4747
context.scope.children.push(reflection);
48-
context.registerReflection(reflection, source);
48+
49+
// target === source happens when doing export * from ...
50+
// and the original symbol is not renamed and exported from the imported module.
51+
context.registerReflection(reflection, target === source ? undefined : source);
4952
context.trigger(Converter.EVENT_CREATE_DECLARATION, reflection);
5053

5154
return reflection;

src/lib/converter/nodes/export.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,13 @@ export class ExportDeclarationConverter extends ConverterNodeComponent<ts.Export
8484
}
8585
});
8686
} else if (node.moduleSpecifier) { // export * from ...
87-
const thisModule = context.getSymbolAtLocation(node.getSourceFile())!;
8887
const sourceFileSymbol = context.getSymbolAtLocation(node.moduleSpecifier);
89-
sourceFileSymbol?.exports?.forEach((symbol, key) => {
90-
// Default exports are not re-exported with export * from
91-
if (key === 'default' as ts.__String) {
92-
return;
93-
}
94-
const source = context.checker.tryGetMemberInModuleExports(key.toString().replace(/^__/, '_'), thisModule);
95-
if (source) {
96-
const target = context.resolveAliasedSymbol(symbol);
97-
createReferenceReflection(context, source, target);
88+
for (const symbol of context.checker.getExportsOfModule(sourceFileSymbol!)) {
89+
if (symbol.name === 'default') { // Default exports are not re-exported with export *
90+
continue;
9891
}
99-
});
92+
createReferenceReflection(context, symbol, context.resolveAliasedSymbol(symbol));
93+
}
10094
}
10195

10296
return context.scope;

0 commit comments

Comments
 (0)