@@ -6896,7 +6896,7 @@ namespace ts {
6896
6896
const name = unescapeLeadingUnderscores(symbol.escapedName);
6897
6897
const isExportEquals = name === InternalSymbolName.ExportEquals;
6898
6898
const isDefault = name === InternalSymbolName.Default;
6899
- const isExportAssignment = isExportEquals || isDefault;
6899
+ const isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault;
6900
6900
// synthesize export = ref
6901
6901
// ref should refer to either be a locally scoped symbol which we need to emit, or
6902
6902
// a reference to another namespace/module which we may need to emit an `import` statement for
@@ -6908,8 +6908,8 @@ namespace ts {
6908
6908
// In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it
6909
6909
// eg, `namespace A { export class B {} }; exports = A.B;`
6910
6910
// Technically, this is all that's required in the case where the assignment is an entity name expression
6911
- const expr = isExportAssignment ? getExportAssignmentExpression( aliasDecl as ExportAssignment | BinaryExpression ) : getPropertyAssignmentAliasLikeExpression(aliasDecl as ShorthandPropertyAssignment | PropertyAssignment | PropertyAccessExpression);
6912
- const first = isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
6911
+ const expr = aliasDecl && ((isExportAssignment( aliasDecl) || isBinaryExpression(aliasDecl)) ? getExportAssignmentExpression(aliasDecl ) : getPropertyAssignmentAliasLikeExpression(aliasDecl as ShorthandPropertyAssignment | PropertyAssignment | PropertyAccessExpression) );
6912
+ const first = expr && isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
6913
6913
const referenced = first && resolveEntityName(first, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration);
6914
6914
if (referenced || target) {
6915
6915
includePrivateSymbol(referenced || target);
@@ -6922,7 +6922,7 @@ namespace ts {
6922
6922
// into the containing scope anyway, so we want to skip the visibility checks.
6923
6923
const oldTrack = context.tracker.trackSymbol;
6924
6924
context.tracker.trackSymbol = noop;
6925
- if (isExportAssignment ) {
6925
+ if (isExportAssignmentCompatibleSymbolName ) {
6926
6926
results.push(factory.createExportAssignment(
6927
6927
/*decorators*/ undefined,
6928
6928
/*modifiers*/ undefined,
@@ -6931,11 +6931,11 @@ namespace ts {
6931
6931
));
6932
6932
}
6933
6933
else {
6934
- if (first === expr) {
6934
+ if (first === expr && first ) {
6935
6935
// serialize as `export {target as name}`
6936
6936
serializeExportSpecifier(name, idText(first));
6937
6937
}
6938
- else if (isClassExpression(expr)) {
6938
+ else if (expr && isClassExpression(expr)) {
6939
6939
serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
6940
6940
}
6941
6941
else {
@@ -6961,7 +6961,7 @@ namespace ts {
6961
6961
const typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
6962
6962
if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
6963
6963
// If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const
6964
- serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? ModifierFlags.None : ModifierFlags.Export);
6964
+ serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? ModifierFlags.None : ModifierFlags.Export);
6965
6965
}
6966
6966
else {
6967
6967
const statement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([
@@ -6974,7 +6974,7 @@ namespace ts {
6974
6974
: name === varName ? ModifierFlags.Export
6975
6975
: ModifierFlags.None);
6976
6976
}
6977
- if (isExportAssignment ) {
6977
+ if (isExportAssignmentCompatibleSymbolName ) {
6978
6978
results.push(factory.createExportAssignment(
6979
6979
/*decorators*/ undefined,
6980
6980
/*modifiers*/ undefined,
0 commit comments