Skip to content

Commit 4016206

Browse files
committed
Merge pull request #2923 from Microsoft/namespaces
Namespaces
2 parents cde3ed0 + 4db61d8 commit 4016206

File tree

199 files changed

+1052
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+1052
-1045
lines changed

src/compiler/checker.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ module ts {
582582
if (moduleSymbol) {
583583
let exportDefaultSymbol = resolveSymbol(moduleSymbol.exports["default"]);
584584
if (!exportDefaultSymbol) {
585-
error(node.name, Diagnostics.External_module_0_has_no_default_export, symbolToString(moduleSymbol));
585+
error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
586586
}
587587
return exportDefaultSymbol;
588588
}
@@ -870,10 +870,10 @@ module ts {
870870
if (sourceFile.symbol) {
871871
return sourceFile.symbol;
872872
}
873-
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName);
873+
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
874874
return;
875875
}
876-
error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
876+
error(moduleReferenceLiteral, Diagnostics.Cannot_find_module_0, moduleName);
877877
}
878878

879879
// An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
@@ -888,7 +888,7 @@ module ts {
888888
function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression): Symbol {
889889
let symbol = resolveExternalModuleSymbol(moduleSymbol);
890890
if (symbol && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) {
891-
error(moduleReferenceExpression, Diagnostics.External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol));
891+
error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol));
892892
symbol = undefined;
893893
}
894894
return symbol;
@@ -5508,7 +5508,7 @@ module ts {
55085508

55095509
switch (container.kind) {
55105510
case SyntaxKind.ModuleDeclaration:
5511-
error(node, Diagnostics.this_cannot_be_referenced_in_a_module_body);
5511+
error(node, Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
55125512
// do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks
55135513
break;
55145514
case SyntaxKind.EnumDeclaration:
@@ -9079,7 +9079,7 @@ module ts {
90799079
let parent = getDeclarationContainer(node);
90809080
if (parent.kind === SyntaxKind.SourceFile && isExternalModule(<SourceFile>parent)) {
90819081
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
9082-
error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module,
9082+
error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module,
90839083
declarationNameToString(name), declarationNameToString(name));
90849084
}
90859085
}
@@ -10494,10 +10494,10 @@ module ts {
1049410494
let firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
1049510495
if (firstNonAmbientClassOrFunc) {
1049610496
if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
10497-
error(node.name, Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
10497+
error(node.name, Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
1049810498
}
1049910499
else if (node.pos < firstNonAmbientClassOrFunc.pos) {
10500-
error(node.name, Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
10500+
error(node.name, Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
1050110501
}
1050210502
}
1050310503

@@ -10513,10 +10513,10 @@ module ts {
1051310513
// Checks for ambient external modules.
1051410514
if (node.name.kind === SyntaxKind.StringLiteral) {
1051510515
if (!isGlobalSourceFile(node.parent)) {
10516-
error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
10516+
error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules);
1051710517
}
1051810518
if (isExternalModuleNameRelative(node.name.text)) {
10519-
error(node.name, Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name);
10519+
error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
1052010520
}
1052110521
}
1052210522
}
@@ -10548,16 +10548,16 @@ module ts {
1054810548
let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.StringLiteral;
1054910549
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) {
1055010550
error(moduleName, node.kind === SyntaxKind.ExportDeclaration ?
10551-
Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module :
10552-
Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
10551+
Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
10552+
Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
1055310553
return false;
1055410554
}
1055510555
if (inAmbientExternalModule && isExternalModuleNameRelative((<LiteralExpression>moduleName).text)) {
1055610556
// TypeScript 1.0 spec (April 2013): 12.1.6
1055710557
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference
1055810558
// other external modules only through top - level external module names.
1055910559
// Relative external module names are not permitted.
10560-
error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name);
10560+
error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
1056110561
return false;
1056210562
}
1056310563
return true;
@@ -10651,14 +10651,14 @@ module ts {
1065110651

1065210652
let inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.StringLiteral;
1065310653
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) {
10654-
error(node, Diagnostics.Export_declarations_are_not_permitted_in_an_internal_module);
10654+
error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
1065510655
}
1065610656
}
1065710657
else {
1065810658
// export * from "foo"
1065910659
let moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
1066010660
if (moduleSymbol && moduleSymbol.exports["export="]) {
10661-
error(node.moduleSpecifier, Diagnostics.External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
10661+
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
1066210662
}
1066310663
}
1066410664
}
@@ -10674,7 +10674,7 @@ module ts {
1067410674
function checkExportAssignment(node: ExportAssignment) {
1067510675
let container = node.parent.kind === SyntaxKind.SourceFile ? <SourceFile>node.parent : <ModuleDeclaration>node.parent.parent;
1067610676
if (container.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>container).name.kind === SyntaxKind.Identifier) {
10677-
error(node, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
10677+
error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
1067810678
return;
1067910679
}
1068010680
// Grammar checking

0 commit comments

Comments
 (0)