31 lines
942 B
Plaintext
31 lines
942 B
Plaintext
==== 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: Neither type 'U' nor type 'T' is assignable to the other.
|
|
y = <U>x;
|
|
~~~~
|
|
!!! error TS2352: Neither type 'T' nor type 'U' is assignable to the other.
|
|
}
|
|
}
|
|
|
|
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: Neither type 'U' nor type 'T' is assignable to the other.
|
|
}
|
|
}
|
|
|
|
var b: B<Date, Date>;
|
|
var c: A<Date, Date> = <A<Date, Date>>b; |