mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Addressing code review feedback.
This commit is contained in:
parent
e4ea5ef1f9
commit
70f8057dc7
@ -5317,7 +5317,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getClassOrFunctionBodyDeclaration(symbol: Symbol): Declaration {
|
||||
function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Declaration {
|
||||
var declarations = symbol.declarations;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var declaration = declarations[i];
|
||||
@ -5325,29 +5325,29 @@ module ts {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
// Return undefined
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function checkModuleDeclaration(node: ModuleDeclaration) {
|
||||
checkDeclarationModifiers(node);
|
||||
var symbol = getSymbolOfNode(node);
|
||||
if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) {
|
||||
var classOrFunc = getClassOrFunctionBodyDeclaration(symbol);
|
||||
var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
||||
if (classOrFunc) {
|
||||
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) {
|
||||
error(node, Diagnostics.Module_declaration_cannot_be_in_different_file_from_class_or_function_with_which_it_is_merged);
|
||||
error(node.name, Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
|
||||
}
|
||||
else if (node.pos < classOrFunc.pos) {
|
||||
error(node, Diagnostics.Module_declaration_cannot_be_located_prior_to_class_or_function_with_which_it_is_merged);
|
||||
error(node.name, Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.StringLiteral) {
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile || node.parent.flags & NodeFlags.ExternalModule) {
|
||||
error(node, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
|
||||
error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
|
||||
}
|
||||
if (isExternalModuleNameRelative(node.name.text)) {
|
||||
error(node, Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name);
|
||||
error(node.name, Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name);
|
||||
}
|
||||
}
|
||||
checkSourceElement(node.body);
|
||||
|
||||
@ -279,8 +279,8 @@ module ts {
|
||||
Interface_0_incorrectly_extends_interface_1: { code: -9999999, category: DiagnosticCategory.Error, key: "Interface '{0}' incorrectly extends interface '{1}'." },
|
||||
Ambient_external_modules_cannot_be_nested_in_other_modules: { code: -9999999, category: DiagnosticCategory.Error, key: "Ambient external modules cannot be nested in other modules." },
|
||||
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: -9999999, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." },
|
||||
Module_declaration_cannot_be_in_different_file_from_class_or_function_with_which_it_is_merged: { code: -9999999, category: DiagnosticCategory.Error, key: "Module declaration cannot be in different file from class or function with which it is merged" },
|
||||
Module_declaration_cannot_be_located_prior_to_class_or_function_with_which_it_is_merged: { code: -9999999, category: DiagnosticCategory.Error, key: "Module declaration cannot be located prior to class or function with which it is merged" },
|
||||
A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: -9999999, category: DiagnosticCategory.Error, key: "A module declaration cannot be in a different file from a class or function with which it is merged" },
|
||||
A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: -9999999, category: DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" },
|
||||
Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: -9999999, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." },
|
||||
Import_declaration_conflicts_with_local_declaration_of_0: { code: -9999999, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" },
|
||||
Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: -9999999, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" },
|
||||
|
||||
@ -1140,11 +1140,11 @@
|
||||
"category": "Error",
|
||||
"code": -9999999
|
||||
},
|
||||
"Module declaration cannot be in different file from class or function with which it is merged": {
|
||||
"A module declaration cannot be in a different file from a class or function with which it is merged": {
|
||||
"category": "Error",
|
||||
"code": -9999999
|
||||
},
|
||||
"Module declaration cannot be located prior to class or function with which it is merged": {
|
||||
"A module declaration cannot be located prior to a class or function with which it is merged": {
|
||||
"category": "Error",
|
||||
"code": -9999999
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user