@@ -693,9 +693,14 @@ module ts {
693693 // The two types of exports are mutually exclusive.
694694 error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
695695 }
696- if (node.exportName.text) {
697- var meaning = SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace;
698- var exportSymbol = resolveName(node, node.exportName.text, meaning, Diagnostics.Cannot_find_name_0, node.exportName);
696+ if (node.expression.kind === SyntaxKind.Identifier && (<Identifier>node.expression).text) {
697+ var exportSymbol = resolveName(node, (<Identifier>node.expression).text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
698+ Diagnostics.Cannot_find_name_0, <Identifier>node.expression);
699+ }
700+ else {
701+ var exportSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "*default*");
702+ exportSymbol.parent = containerSymbol;
703+ (<TransientSymbol>exportSymbol).type = checkExpression(node.expression);
699704 }
700705 symbolLinks.exportAssignmentSymbol = exportSymbol || unknownSymbol;
701706 }
@@ -9537,19 +9542,6 @@ module ts {
95379542 if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
95389543 grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
95399544 }
9540- else if (node.name.kind === SyntaxKind.Identifier && node.body.kind === SyntaxKind.ModuleBlock) {
9541- var statements = (<ModuleBlock>node.body).statements;
9542- for (var i = 0, n = statements.length; i < n; i++) {
9543- var statement = statements[i];
9544-
9545- // TODO: AndersH: No reason to do a separate pass over the statements for this check, we should
9546- // just fold it into checkExportAssignment.
9547- if (statement.kind === SyntaxKind.ExportAssignment) {
9548- // Export assignments are not allowed in an internal module
9549- grammarErrorOnNode(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
9550- }
9551- }
9552- }
95539545 }
95549546
95559547 checkCollisionWithCapturedThisVariable(node, node.name);
@@ -9704,11 +9696,14 @@ module ts {
97049696 }
97059697
97069698 function checkExportAssignment(node: ExportAssignment) {
9699+ if (node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.Identifier) {
9700+ error(node, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
9701+ return;
9702+ }
97079703 // Grammar checking
97089704 if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
97099705 grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
97109706 }
9711-
97129707 var container = node.parent;
97139708 if (container.kind !== SyntaxKind.SourceFile) {
97149709 // In a module, the immediate parent will be a block, so climb up one more parent
@@ -9906,6 +9901,7 @@ module ts {
99069901 case SyntaxKind.ClassDeclaration:
99079902 case SyntaxKind.EnumDeclaration:
99089903 case SyntaxKind.EnumMember:
9904+ case SyntaxKind.ExportAssignment:
99099905 case SyntaxKind.SourceFile:
99109906 forEachChild(node, checkFunctionExpressionBodies);
99119907 break;
@@ -10165,7 +10161,7 @@ module ts {
1016510161 }
1016610162
1016710163 if (nodeOnRightSide.parent.kind === SyntaxKind.ExportAssignment) {
10168- return (<ExportAssignment>nodeOnRightSide.parent).exportName === nodeOnRightSide && <ExportAssignment>nodeOnRightSide.parent;
10164+ return (<ExportAssignment>nodeOnRightSide.parent).expression === <Node> nodeOnRightSide && <ExportAssignment>nodeOnRightSide.parent;
1016910165 }
1017010166
1017110167 return undefined;
0 commit comments