Improve error message for type parameter extending union

This commit is contained in:
Jason Freeman 2015-04-15 11:46:21 -07:00
parent 1d8fb49f4c
commit 628a5baf4a
2 changed files with 6 additions and 6 deletions

View File

@ -4074,8 +4074,8 @@ module ts {
}
}
else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) {
if (result = isRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
errorInfo = saveErrorInfo;
if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) {
return result;
}
}

View File

@ -1,8 +1,8 @@
tests/cases/compiler/typeParameterDiamond3.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'.
Type 'T' is not assignable to type 'Top'.
tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' is not assignable to type 'T | U'.
Type 'Bottom' is not assignable to type 'U'.
Type 'Top | T | U' is not assignable to type 'U'.
Type 'Top | T | U' is not assignable to type 'T | U'.
Type 'Top' is not assignable to type 'T | U'.
Type 'Top' is not assignable to type 'U'.
tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'.
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
middle = bottom;
~~~~~~
!!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'.
!!! error TS2322: Type 'Bottom' is not assignable to type 'U'.
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'.
!!! error TS2322: Type 'Top | T | U' is not assignable to type 'T | U'.
!!! error TS2322: Type 'Top' is not assignable to type 'T | U'.
!!! error TS2322: Type 'Top' is not assignable to type 'U'.
top = bottom;
~~~