2014-09-12 22:35:07 +02:00
|
|
|
tests/cases/compiler/genericTypeAssertions6.ts(8,13): error TS2352: Neither type 'U' nor type 'T' is assignable to the other.
|
|
|
|
tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Neither type 'T' nor type 'U' is assignable to the other.
|
|
|
|
tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Neither type 'U' nor type 'T' is assignable to the other.
|
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== 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;
|
|
|
|
~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2352: Neither type 'U' nor type 'T' is assignable to the other.
|
2014-07-13 01:04:16 +02:00
|
|
|
y = <U>x;
|
|
|
|
~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2352: Neither type 'T' nor type 'U' is assignable to the other.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
~~~~~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2352: Neither type 'U' nor type 'T' is assignable to the other.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var b: B<Date, Date>;
|
|
|
|
var c: A<Date, Date> = <A<Date, Date>>b;
|