Skip to content

Commit 1666a56

Browse files
author
Prateek Goel
committed
Error messages and tests
1 parent 8ff5392 commit 1666a56

6 files changed

+18
-18
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5773,7 +5773,7 @@ namespace ts {
57735773
return type.resolvedBaseTypes = emptyArray;
57745774
}
57755775
if (!isValidBaseType(baseType)) {
5776-
error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType));
5776+
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));
57775777
return type.resolvedBaseTypes = emptyArray;
57785778
}
57795779
if (type === baseType || hasBaseType(baseType, type)) {
@@ -5831,7 +5831,7 @@ namespace ts {
58315831
}
58325832
}
58335833
else {
5834-
error(node, Diagnostics.An_interface_can_only_extend_an_object_or_intersection_type_with_statically_known_members);
5834+
error(node, Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
58355835
}
58365836
}
58375837
}
@@ -25979,7 +25979,7 @@ namespace ts {
2597925979
}
2598025980
}
2598125981
else {
25982-
error(typeRefNode, Diagnostics.A_class_can_only_implement_an_object_or_intersection_type_with_statically_known_members);
25982+
error(typeRefNode, Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
2598325983
}
2598425984
}
2598525985
}

src/compiler/diagnosticMessages.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@
10561056
"category": "Error",
10571057
"code": 2311
10581058
},
1059-
"An interface can only extend an object or intersection type with statically known members.": {
1059+
"An interface can only extend an object type or intersection of object types with statically known members.": {
10601060
"category": "Error",
10611061
"code": 2312
10621062
},
@@ -1484,7 +1484,7 @@
14841484
"category": "Error",
14851485
"code": 2420
14861486
},
1487-
"A class can only implement an object or intersection type with statically known members.": {
1487+
"A class can only implement an object type or intersection of object types with statically known members.": {
14881488
"category": "Error",
14891489
"code": 2422
14901490
},
@@ -1816,7 +1816,7 @@
18161816
"category": "Error",
18171817
"code": 2508
18181818
},
1819-
"Base constructor return type '{0}' is not a class or interface type.": {
1819+
"Base constructor return type '{0}' is not an object type or intersection of object types with statically known members.": {
18201820
"category": "Error",
18211821
"code": 2509
18221822
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'.
2-
tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface.
2+
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.
33

44

55
==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ====
@@ -8,4 +8,4 @@ tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An
88
!!! error TS2304: Cannot find name 'T'.
99
interface I<T> extends T { }
1010
~
11-
!!! error TS2312: An interface may only extend a class or another interface.
11+
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.

tests/baselines/reference/interfaceExtendsObjectIntersectionErrors.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
5151
Type 'I23' is not assignable to type 'T1'.
5252
Types of property 'a' are incompatible.
5353
Type 'string' is not assignable to type 'number'.
54-
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(46,23): error TS2312: An interface may only extend a class or another interface.
55-
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface may only extend a class or another interface.
54+
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.
55+
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.
5656

5757

5858
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ====
@@ -177,8 +177,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
177177

178178
interface I30 extends U { x: string }
179179
~
180-
!!! error TS2312: An interface may only extend a class or another interface.
180+
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
181181
interface I31<T> extends T { x: string }
182182
~
183-
!!! error TS2312: An interface may only extend a class or another interface.
183+
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
184184

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'.
2-
tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface.
2+
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.
33

44

55
==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ====
@@ -8,4 +8,4 @@ tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class ma
88
!!! error TS2304: Cannot find name 'T'.
99
class C2<T> implements T {}
1010
~
11-
!!! error TS2422: A class may only implement another class or interface.
11+
!!! error TS2422: A class can only implement an object type or intersection of object types with statically known members.

tests/baselines/reference/typeParameterAsBaseType.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'.
22
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'.
3-
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface.
4-
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface.
3+
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.
4+
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.
55

66

77
==== tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts (4 errors) ====
@@ -17,9 +17,9 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e
1717

1818
interface I<T> extends T { }
1919
~
20-
!!! error TS2312: An interface may only extend a class or another interface.
20+
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
2121
interface I2<T, U> extends U { }
2222
~
23-
!!! error TS2312: An interface may only extend a class or another interface.
23+
!!! error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
2424

2525

0 commit comments

Comments
 (0)