2014-11-05 21:26:03 +01:00
|
|
|
tests/cases/compiler/genericCloneReturnTypes.ts(25,1): error TS2322: Type 'Bar<string>' is not assignable to type 'Bar<number>'.
|
2014-09-12 22:35:07 +02:00
|
|
|
Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/genericCloneReturnTypes.ts (1 errors) ====
|
|
|
|
class Bar<T> {
|
|
|
|
|
|
|
|
public size: number;
|
|
|
|
public t: T;
|
|
|
|
|
|
|
|
constructor(x: number) {
|
|
|
|
|
|
|
|
this.size = x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public clone() {
|
|
|
|
|
|
|
|
return new Bar<T>(this.size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var b: Bar<number>;
|
|
|
|
|
|
|
|
var b2 = b.clone();
|
|
|
|
var b3: Bar<string>;
|
|
|
|
b = b2;
|
|
|
|
b = b3;
|
|
|
|
~
|
2014-11-05 21:26:03 +01:00
|
|
|
!!! error TS2322: Type 'Bar<string>' is not assignable to type 'Bar<number>'.
|
|
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|