1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Type 'U' cannot be converted to type 'T'.
tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Type 'T' cannot be converted to type 'U'.
tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Type 'U' cannot be converted to type 'T'.
Type 'Date' is not comparable to type 'T'.
==== tests/cases/compiler/genericTypeAssertions6.ts (3 errors) ====
class A<T,U> {
constructor(x) {
var y = <T>x;
var z = <U>x;
}
f(x: T, y: U) {
x = <T>y;
~~~~
!!! error TS2352: Type 'U' cannot be converted to type 'T'.
y = <U>x;
~~~~
!!! error TS2352: Type 'T' cannot be converted to type 'U'.
}
}
class B<T extends Date, U extends Date> extends A<T, U> {
g(x: T) {
var a: Date = x;
var b = <Date>x;
var c = <T>new Date();
var d = <U>new Date();
var e = <T><U>new Date();
~~~~~~~~~~~~~~~~
!!! error TS2352: Type 'U' cannot be converted to type 'T'.
!!! error TS2352: Type 'Date' is not comparable to type 'T'.
}
}
var b: B<Date, Date>;
var c: A<Date, Date> = <A<Date, Date>>b;
|