Retain undefined initializations (#36806)

* Emit an export assignment even when the initializer is elided

* User a void 0; and elide assignments for enum/namespace-sourced exported variables

* HAHA, SIMPLIFY GREATLY
This commit is contained in:
Wesley Wigham
2020-02-26 08:48:18 -08:00
committed by GitHub
parent 56b6d0d666
commit 454cdb8279
77 changed files with 226 additions and 15 deletions

View File

@@ -1180,7 +1180,6 @@ namespace ts {
let modifiers: NodeArray<Modifier> | undefined;
// If we're exporting these variables, then these just become assignments to 'exports.x'.
// We only want to emit assignments for variables with initializers.
for (const variable of node.declarationList.declarations) {
if (isIdentifier(variable.name) && isLocalName(variable.name)) {
if (!modifiers) {
@@ -1189,7 +1188,7 @@ namespace ts {
variables = append(variables, variable);
}
else if (variable.initializer) {
else {
expressions = append(expressions, transformInitializedVariable(variable));
}
}
@@ -1259,7 +1258,7 @@ namespace ts {
),
/*location*/ node.name
),
visitNode(node.initializer, moduleExpressionElementVisitor)
node.initializer ? visitNode(node.initializer, moduleExpressionElementVisitor) : createVoidZero()
);
}
}