@@ -8268,7 +8268,7 @@ module ts {
8268
8268
// Do not use hasDynamicName here, because that returns false for well known symbols.
8269
8269
// We want to perform checkComputedPropertyName for all computed properties, including
8270
8270
// well known symbols.
8271
- if (node.name.kind === SyntaxKind.ComputedPropertyName) {
8271
+ if (node.name && node.name .kind === SyntaxKind.ComputedPropertyName) {
8272
8272
// This check will account for methods in class/interface declarations,
8273
8273
// as well as accessors in classes/object literals
8274
8274
checkComputedPropertyName(<ComputedPropertyName>node.name);
@@ -8998,10 +8998,12 @@ module ts {
8998
8998
// Grammar checking
8999
8999
checkGrammarClassDeclarationHeritageClauses(node);
9000
9000
9001
- checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0);
9001
+ if (node.name) {
9002
+ checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0);
9003
+ checkCollisionWithCapturedThisVariable(node, node.name);
9004
+ checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
9005
+ }
9002
9006
checkTypeParameters(node.typeParameters);
9003
- checkCollisionWithCapturedThisVariable(node, node.name);
9004
- checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
9005
9007
checkExportsOnMergedDeclarations(node);
9006
9008
var symbol = getSymbolOfNode(node);
9007
9009
var type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
@@ -9014,9 +9016,9 @@ module ts {
9014
9016
if (type.baseTypes.length) {
9015
9017
if (produceDiagnostics) {
9016
9018
var baseType = type.baseTypes[0];
9017
- checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Class_0_incorrectly_extends_base_class_1);
9019
+ checkTypeAssignableTo(type, baseType, node.name || node , Diagnostics.Class_0_incorrectly_extends_base_class_1);
9018
9020
var staticBaseType = getTypeOfSymbol(baseType.symbol);
9019
- checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name,
9021
+ checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name || node ,
9020
9022
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
9021
9023
if (baseType.symbol !== resolveEntityName(baseTypeNode.typeName, SymbolFlags.Value)) {
9022
9024
error(baseTypeNode, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType));
@@ -9038,7 +9040,7 @@ module ts {
9038
9040
if (t !== unknownType) {
9039
9041
var declaredType = (t.flags & TypeFlags.Reference) ? (<TypeReference>t).target : t;
9040
9042
if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) {
9041
- checkTypeAssignableTo(type, t, node.name, Diagnostics.Class_0_incorrectly_implements_interface_1);
9043
+ checkTypeAssignableTo(type, t, node.name || node , Diagnostics.Class_0_incorrectly_implements_interface_1);
9042
9044
}
9043
9045
else {
9044
9046
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
@@ -10414,6 +10416,10 @@ module ts {
10414
10416
10415
10417
function generateNames(node: Node) {
10416
10418
switch (node.kind) {
10419
+ case SyntaxKind.FunctionDeclaration:
10420
+ case SyntaxKind.ClassDeclaration:
10421
+ generateNameForFunctionOrClassDeclaration(<Declaration>node);
10422
+ break;
10417
10423
case SyntaxKind.ModuleDeclaration:
10418
10424
generateNameForModuleOrEnum(<ModuleDeclaration>node);
10419
10425
generateNames((<ModuleDeclaration>node).body);
@@ -10427,6 +10433,9 @@ module ts {
10427
10433
case SyntaxKind.ExportDeclaration:
10428
10434
generateNameForExportDeclaration(<ExportDeclaration>node);
10429
10435
break;
10436
+ case SyntaxKind.ExportAssignment:
10437
+ generateNameForExportAssignment(<ExportAssignment>node);
10438
+ break;
10430
10439
case SyntaxKind.SourceFile:
10431
10440
case SyntaxKind.ModuleBlock:
10432
10441
forEach((<SourceFile | ModuleBlock>node).statements, generateNames);
@@ -10464,6 +10473,12 @@ module ts {
10464
10473
getNodeLinks(node).generatedName = unescapeIdentifier(name);
10465
10474
}
10466
10475
10476
+ function generateNameForFunctionOrClassDeclaration(node: Declaration) {
10477
+ if (!node.name) {
10478
+ assignGeneratedName(node, makeUniqueName("default"));
10479
+ }
10480
+ }
10481
+
10467
10482
function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) {
10468
10483
if (node.name.kind === SyntaxKind.Identifier) {
10469
10484
var name = node.name.text;
@@ -10490,9 +10505,15 @@ module ts {
10490
10505
generateNameForImportOrExportDeclaration(node);
10491
10506
}
10492
10507
}
10508
+
10509
+ function generateNameForExportAssignment(node: ExportAssignment) {
10510
+ if (node.expression.kind !== SyntaxKind.Identifier) {
10511
+ assignGeneratedName(node, makeUniqueName("default"));
10512
+ }
10513
+ }
10493
10514
}
10494
10515
10495
- function getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration ) {
10516
+ function getGeneratedNameForNode(node: Node ) {
10496
10517
var links = getNodeLinks(node);
10497
10518
if (!links.generatedName) {
10498
10519
getGeneratedNamesForSourceFile(getSourceFile(node));
0 commit comments