Skip to content

Commit 8c80792

Browse files
committed
emit publish of exported values in destructuring
1 parent 7bced68 commit 8c80792

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/compiler/emitter.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -2588,14 +2588,35 @@ var __param = this.__param || function(index, decorator) { return function (targ
25882588
}
25892589

25902590
renameNonTopLevelLetAndConst(name);
2591-
if (name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement)) {
2591+
2592+
const isVariableDeclarationOrBindingElement =
2593+
name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement);
2594+
2595+
let emitPublishOfExportedValue = false;
2596+
if (currentFileIsEmittedAsSystemModule() && !nodeIsSynthesized(name)) {
2597+
let nodeToCheck = isVariableDeclarationOrBindingElement ? name.parent : resolver.getReferencedValueDeclaration(name);
2598+
emitPublishOfExportedValue = nodeToCheck && (getCombinedNodeFlags(nodeToCheck) & NodeFlags.Export) && isSourceFileLevelDeclaration(nodeToCheck);
2599+
}
2600+
2601+
if (emitPublishOfExportedValue) {
2602+
write(`${exportFunctionForFile}("`);
2603+
emitNodeWithoutSourceMap(name);
2604+
write(`", `);
2605+
}
2606+
2607+
if (isVariableDeclarationOrBindingElement) {
25922608
emitModuleMemberName(<Declaration>name.parent);
25932609
}
25942610
else {
25952611
emit(name);
25962612
}
2613+
25972614
write(" = ");
25982615
emit(value);
2616+
2617+
if (emitPublishOfExportedValue) {
2618+
write(")");
2619+
}
25992620
}
26002621

26012622
function ensureIdentifier(expr: Expression): Expression {

0 commit comments

Comments
 (0)