@@ -6896,7 +6896,7 @@ namespace ts {
68966896 const name = unescapeLeadingUnderscores(symbol.escapedName);
68976897 const isExportEquals = name === InternalSymbolName.ExportEquals;
68986898 const isDefault = name === InternalSymbolName.Default;
6899- const isExportAssignment = isExportEquals || isDefault;
6899+ const isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault;
69006900 // synthesize export = ref
69016901 // ref should refer to either be a locally scoped symbol which we need to emit, or
69026902 // a reference to another namespace/module which we may need to emit an `import` statement for
@@ -6908,8 +6908,8 @@ namespace ts {
69086908 // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it
69096909 // eg, `namespace A { export class B {} }; exports = A.B;`
69106910 // 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;
69136913 const referenced = first && resolveEntityName(first, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration);
69146914 if (referenced || target) {
69156915 includePrivateSymbol(referenced || target);
@@ -6922,7 +6922,7 @@ namespace ts {
69226922 // into the containing scope anyway, so we want to skip the visibility checks.
69236923 const oldTrack = context.tracker.trackSymbol;
69246924 context.tracker.trackSymbol = noop;
6925- if (isExportAssignment ) {
6925+ if (isExportAssignmentCompatibleSymbolName ) {
69266926 results.push(factory.createExportAssignment(
69276927 /*decorators*/ undefined,
69286928 /*modifiers*/ undefined,
@@ -6931,11 +6931,11 @@ namespace ts {
69316931 ));
69326932 }
69336933 else {
6934- if (first === expr) {
6934+ if (first === expr && first ) {
69356935 // serialize as `export {target as name}`
69366936 serializeExportSpecifier(name, idText(first));
69376937 }
6938- else if (isClassExpression(expr)) {
6938+ else if (expr && isClassExpression(expr)) {
69396939 serializeExportSpecifier(name, getInternalSymbolName(target, symbolName(target)));
69406940 }
69416941 else {
@@ -6961,7 +6961,7 @@ namespace ts {
69616961 const typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
69626962 if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
69636963 // 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);
69656965 }
69666966 else {
69676967 const statement = factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([
@@ -6974,7 +6974,7 @@ namespace ts {
69746974 : name === varName ? ModifierFlags.Export
69756975 : ModifierFlags.None);
69766976 }
6977- if (isExportAssignment ) {
6977+ if (isExportAssignmentCompatibleSymbolName ) {
69786978 results.push(factory.createExportAssignment(
69796979 /*decorators*/ undefined,
69806980 /*modifiers*/ undefined,
0 commit comments