mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixed some error messages.
This commit is contained in:
+15
-9
@@ -6701,10 +6701,12 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In a super call, the methods cannot be accessed if the method is abstract.
|
||||
// Note that a member cannot be private and abstract -- this is checked elsewhere.
|
||||
if (flags & NodeFlags.Abstract) {
|
||||
// Get the declaring the class instance type for the error message.
|
||||
// A method cannot be accessed in a super call if the method is abstract.
|
||||
// This error could mask a private property access error. But, a member
|
||||
// cannot simultaneously be private and abstract, so this will trigger an
|
||||
// additional error elsewhere.
|
||||
|
||||
declaringClass = <InterfaceType>getDeclaredTypeOfSymbol(prop.parent);
|
||||
|
||||
error(errorNode, Diagnostics.Abstract_method_0_1_cannot_be_accessed_via_super_expression, typeToString(declaringClass), symbolToString(prop));
|
||||
@@ -9145,7 +9147,7 @@ namespace ts {
|
||||
error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature);
|
||||
}
|
||||
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) : NodeFlags {
|
||||
function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags {
|
||||
let flags = getCombinedNodeFlags(n);
|
||||
if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) {
|
||||
if (!(flags & NodeFlags.Ambient)) {
|
||||
@@ -9192,7 +9194,7 @@ namespace ts {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
|
||||
}
|
||||
else if (deviation & NodeFlags.Abstract) {
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract, "abstract");
|
||||
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -10732,7 +10734,7 @@ namespace ts {
|
||||
|
||||
// Classes containing abstract methods must be marked abstract
|
||||
if (!(node.flags & NodeFlags.Abstract) && forEach(node.members, element => element.flags & NodeFlags.Abstract)) {
|
||||
error(node, Diagnostics.Classes_containing_abstract_functions_must_be_marked_abstract);
|
||||
error(node, Diagnostics.Classes_containing_abstract_methods_must_be_marked_abstract);
|
||||
}
|
||||
|
||||
if (produceDiagnostics) {
|
||||
@@ -10785,8 +10787,8 @@ namespace ts {
|
||||
|
||||
// It is an error to inherit an abstract member without implementing it or being declared abstract.
|
||||
if ((baseDeclarationFlags & NodeFlags.Abstract) && !(derivedClassDecl.flags & NodeFlags.Abstract)) {
|
||||
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2,
|
||||
typeToString(type), typeToString(baseType), symbolToString(baseProperty));
|
||||
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2,
|
||||
typeToString(type), symbolToString(baseProperty), typeToString(baseType));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -12821,7 +12823,11 @@ namespace ts {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
|
||||
}
|
||||
else if (flags & NodeFlags.Abstract) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
|
||||
if (modifier.kind === SyntaxKind.PrivateKeyword) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract")}
|
||||
else {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
|
||||
}
|
||||
}
|
||||
flags |= modifierToFlag(modifier.kind);
|
||||
break;
|
||||
|
||||
@@ -396,8 +396,8 @@ namespace ts {
|
||||
Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." },
|
||||
Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be `abstract` or not `abstract." },
|
||||
Abstract_method_0_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}.{1}' cannot be accessed via super expression." },
|
||||
Classes_containing_abstract_functions_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract functions must be marked abstract." },
|
||||
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'." },
|
||||
Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." },
|
||||
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
|
||||
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
|
||||
@@ -1571,11 +1571,11 @@
|
||||
"category": "Error",
|
||||
"code": 2513
|
||||
},
|
||||
"Classes containing abstract functions must be marked abstract.": {
|
||||
"Classes containing abstract methods must be marked abstract.": {
|
||||
"category": "Error",
|
||||
"code": 2514
|
||||
},
|
||||
"Non-abstract class '{0}' does not implement inherited abstract member '{1}.{2}'.": {
|
||||
"Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 2515
|
||||
},
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ class A {
|
||||
}
|
||||
|
||||
abstract class B {
|
||||
foo(): number { return bar(); }
|
||||
foo(): number { return this.bar(); }
|
||||
abstract bar() : number;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ abstract class G {
|
||||
y : number;
|
||||
abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent
|
||||
|
||||
abstract nom() boolean;
|
||||
nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads.
|
||||
abstract nom(): boolean;
|
||||
nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads.
|
||||
}
|
||||
|
||||
class H { // error -- not declared abstract
|
||||
|
||||
Reference in New Issue
Block a user