Merge pull request #28015 from prateekgoel/error-messages
Error messages for extending a specific type
This commit is contained in:
commit
f4fb28daa9
6 changed files with 18 additions and 18 deletions
|
@ -5894,7 +5894,7 @@ namespace ts {
|
|||
return type.resolvedBaseTypes = emptyArray;
|
||||
}
|
||||
if (!isValidBaseType(baseType)) {
|
||||
error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType));
|
||||
error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(baseType));
|
||||
return type.resolvedBaseTypes = emptyArray;
|
||||
}
|
||||
if (type === baseType || hasBaseType(baseType, type)) {
|
||||
|
@ -5952,7 +5952,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.An_interface_may_only_extend_a_class_or_another_interface);
|
||||
error(node, Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26454,7 +26454,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
|
||||
error(typeRefNode, Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1060,7 +1060,7 @@
|
|||
"category": "Error",
|
||||
"code": 2311
|
||||
},
|
||||
"An interface may only extend a class or another interface.": {
|
||||
"An interface can only extend an object type or intersection of object types with statically known members.": {
|
||||
"category": "Error",
|
||||
"code": 2312
|
||||
},
|
||||
|
@ -1488,7 +1488,7 @@
|
|||
"category": "Error",
|
||||
"code": 2420
|
||||
},
|
||||
"A class may only implement another class or interface.": {
|
||||
"A class can only implement an object type or intersection of object types with statically known members.": {
|
||||
"category": "Error",
|
||||
"code": 2422
|
||||
},
|
||||
|
@ -1820,7 +1820,7 @@
|
|||
"category": "Error",
|
||||
"code": 2508
|
||||
},
|
||||
"Base constructor return type '{0}' is not a class or interface type.": {
|
||||
"Base constructor return type '{0}' is not an object type or intersection of object types with statically known members.": {
|
||||
"category": "Error",
|
||||
"code": 2509
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ====
|
||||
|
@ -8,4 +8,4 @@ tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An
|
|||
!!! error TS2304: Cannot find name 'T'.
|
||||
interface I<T> extends T { }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
|
@ -51,8 +51,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
Type 'I23' is not assignable to type 'T1'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(46,23): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(46,23): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ====
|
||||
|
@ -177,8 +177,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
|
||||
interface I30 extends U { x: string }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
interface I31<T> extends T { x: string }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface.
|
||||
tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class can only implement an object type or intersection of object types with statically known members.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ====
|
||||
|
@ -8,4 +8,4 @@ tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class ma
|
|||
!!! error TS2304: Cannot find name 'T'.
|
||||
class C2<T> implements T {}
|
||||
~
|
||||
!!! error TS2422: A class may only implement another class or interface.
|
||||
!!! error TS2422: A class can only implement an object type or intersection of object types with statically known members.
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts (4 errors) ====
|
||||
|
@ -17,9 +17,9 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e
|
|||
|
||||
interface I<T> extends T { }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
interface I2<T, U> extends U { }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
||||
|
Loading…
Reference in a new issue