mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Address code review
This commit is contained in:
@@ -12446,10 +12446,11 @@ module ts {
|
||||
if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
|
||||
let nameText = declarationNameToString(identifier);
|
||||
|
||||
// We are checking if this parameter's name is of method or constructor so that we can give more explicit errors because
|
||||
// invalid usage error particularly of "arguments" is very common mistake
|
||||
if (contextNode && (contextNode.parent.kind === SyntaxKind.MethodDeclaration || contextNode.parent.kind === SyntaxKind.Constructor)) {
|
||||
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_because_class_definition_is_considered_a_strict_mode_code, nameText);
|
||||
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
|
||||
// if so, we would like to give more explicit invalid usage error.
|
||||
// This will be particularly helpful in the case of "arguments" as such case is very common mistake.
|
||||
if (getAncestor(name, SyntaxKind.ClassDeclaration) || getAncestor(name, SyntaxKind.ClassExpression)) {
|
||||
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
|
||||
}
|
||||
else {
|
||||
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
|
||||
|
||||
@@ -167,7 +167,7 @@ module ts {
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
|
||||
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
|
||||
Invalid_use_of_0_because_class_definition_is_considered_a_strict_mode_code: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' because class definition is considered a strict mode code " },
|
||||
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
|
||||
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
|
||||
@@ -659,7 +659,7 @@
|
||||
"category": "Error",
|
||||
"code": 1209
|
||||
},
|
||||
"Invalid use of '{0}' because class definition is considered a strict mode code ": {
|
||||
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1210
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user