Add new error message when class implements class #19793

This commit is contained in:
Charles Pierce
2017-12-05 21:18:31 -08:00
parent 3a3bb8e3f0
commit 472f087e69
14 changed files with 109 additions and 37 deletions

View File

@@ -22657,7 +22657,12 @@ namespace ts {
const t = getTypeFromTypeNode(typeRefNode);
if (t !== unknownType) {
if (isValidBaseType(t)) {
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1);
checkTypeAssignableTo(typeWithThis,
getTypeWithThisArgument(t, type.thisType),
node.name || node,
t.symbol.flags & SymbolFlags.Class ?
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);

View File

@@ -2276,6 +2276,10 @@
"category": "Error",
"code": 2719
},
"Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?": {
"category": "Error",
"code": 2720
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",

View File

@@ -1,7 +1,8 @@
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: [Diagnostics.Class_0_incorrectly_implements_interface_1.code],
errorCodes: [Diagnostics.Class_0_incorrectly_implements_interface_1.code,
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code],
getCodeActions: getActionForClassLikeIncorrectImplementsInterface
});