Skip to content

Commit 628a5ba

Browse files
committed
Improve error message for type parameter extending union
1 parent 1d8fb49 commit 628a5ba

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,8 +4074,8 @@ module ts {
40744074
}
40754075
}
40764076
else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) {
4077-
if (result = isRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors)) {
4078-
errorInfo = saveErrorInfo;
4077+
errorInfo = saveErrorInfo;
4078+
if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) {
40794079
return result;
40804080
}
40814081
}

tests/baselines/reference/typeParameterDiamond3.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests/cases/compiler/typeParameterDiamond3.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'.
22
Type 'T' is not assignable to type 'Top'.
33
tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' is not assignable to type 'T | U'.
4-
Type 'Bottom' is not assignable to type 'U'.
5-
Type 'Top | T | U' is not assignable to type 'U'.
4+
Type 'Top | T | U' is not assignable to type 'T | U'.
5+
Type 'Top' is not assignable to type 'T | U'.
66
Type 'Top' is not assignable to type 'U'.
77
tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'.
88
Type 'Top | T | U' is not assignable to type 'Top'.
@@ -24,8 +24,8 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom
2424
middle = bottom;
2525
~~~~~~
2626
!!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'.
27-
!!! error TS2322: Type 'Bottom' is not assignable to type 'U'.
28-
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'.
27+
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'.
28+
!!! error TS2322: Type 'Top' is not assignable to type 'T | U'.
2929
!!! error TS2322: Type 'Top' is not assignable to type 'U'.
3030
top = bottom;
3131
~~~

0 commit comments

Comments
 (0)