@@ -693,9 +693,14 @@ module ts {
693
693
// The two types of exports are mutually exclusive.
694
694
error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
695
695
}
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);
699
704
}
700
705
symbolLinks.exportAssignmentSymbol = exportSymbol || unknownSymbol;
701
706
}
@@ -9537,19 +9542,6 @@ module ts {
9537
9542
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
9538
9543
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
9539
9544
}
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
- }
9553
9545
}
9554
9546
9555
9547
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -9704,11 +9696,14 @@ module ts {
9704
9696
}
9705
9697
9706
9698
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
+ }
9707
9703
// Grammar checking
9708
9704
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
9709
9705
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
9710
9706
}
9711
-
9712
9707
var container = node.parent;
9713
9708
if (container.kind !== SyntaxKind.SourceFile) {
9714
9709
// In a module, the immediate parent will be a block, so climb up one more parent
@@ -9906,6 +9901,7 @@ module ts {
9906
9901
case SyntaxKind.ClassDeclaration:
9907
9902
case SyntaxKind.EnumDeclaration:
9908
9903
case SyntaxKind.EnumMember:
9904
+ case SyntaxKind.ExportAssignment:
9909
9905
case SyntaxKind.SourceFile:
9910
9906
forEachChild(node, checkFunctionExpressionBodies);
9911
9907
break;
@@ -10165,7 +10161,7 @@ module ts {
10165
10161
}
10166
10162
10167
10163
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;
10169
10165
}
10170
10166
10171
10167
return undefined;
0 commit comments